memory.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. const {
  6. Arg,
  7. RetVal,
  8. types,
  9. generateActorSpec,
  10. } = require("devtools/shared/protocol");
  11. types.addDictType("AllocationsRecordingOptions", {
  12. // The probability we sample any given allocation when recording
  13. // allocations. Must be between 0.0 and 1.0. Defaults to 1.0, or sampling
  14. // every allocation.
  15. probability: "number",
  16. // The maximum number of of allocation events to keep in the allocations
  17. // log. If new allocations arrive, when we are already at capacity, the oldest
  18. // allocation event is lost. This number must fit in a 32 bit signed integer.
  19. maxLogLength: "number"
  20. });
  21. const memorySpec = generateActorSpec({
  22. typeName: "memory",
  23. /**
  24. * The set of unsolicited events the MemoryActor emits that will be sent over
  25. * the RDP (by protocol.js).
  26. */
  27. events: {
  28. // Same format as the data passed to the
  29. // `Debugger.Memory.prototype.onGarbageCollection` hook. See
  30. // `js/src/doc/Debugger/Debugger.Memory.md` for documentation.
  31. "garbage-collection": {
  32. type: "garbage-collection",
  33. data: Arg(0, "json"),
  34. },
  35. // Same data as the data from `getAllocations` -- only fired if
  36. // `autoDrain` set during `startRecordingAllocations`.
  37. "allocations": {
  38. type: "allocations",
  39. data: Arg(0, "json"),
  40. },
  41. },
  42. methods: {
  43. attach: {
  44. request: {},
  45. response: {
  46. type: "attached"
  47. }
  48. },
  49. detach: {
  50. request: {},
  51. response: {
  52. type: "detached"
  53. }
  54. },
  55. getState: {
  56. response: {
  57. state: RetVal(0, "string")
  58. }
  59. },
  60. takeCensus: {
  61. request: {},
  62. response: RetVal("json")
  63. },
  64. startRecordingAllocations: {
  65. request: {
  66. options: Arg(0, "nullable:AllocationsRecordingOptions")
  67. },
  68. response: {
  69. // Accept `nullable` in the case of server Gecko <= 37, handled on the front
  70. value: RetVal(0, "nullable:number")
  71. }
  72. },
  73. stopRecordingAllocations: {
  74. request: {},
  75. response: {
  76. // Accept `nullable` in the case of server Gecko <= 37, handled on the front
  77. value: RetVal(0, "nullable:number")
  78. }
  79. },
  80. getAllocationsSettings: {
  81. request: {},
  82. response: {
  83. options: RetVal(0, "json")
  84. }
  85. },
  86. getAllocations: {
  87. request: {},
  88. response: RetVal("json")
  89. },
  90. forceGarbageCollection: {
  91. request: {},
  92. response: {}
  93. },
  94. forceCycleCollection: {
  95. request: {},
  96. response: {}
  97. },
  98. measure: {
  99. request: {},
  100. response: RetVal("json"),
  101. },
  102. residentUnique: {
  103. request: {},
  104. response: { value: RetVal("number") }
  105. },
  106. saveHeapSnapshot: {
  107. request: {
  108. boundaries: Arg(0, "nullable:json")
  109. },
  110. response: {
  111. snapshotId: RetVal("string")
  112. }
  113. },
  114. },
  115. });
  116. exports.memorySpec = memorySpec;