@@ -1788,41 +1788,23 @@ const profile = handle.stop();
17881788console .log (profile);
17891789` ` `
17901790
1791- ## ` v8 .heapProfilerConstants `
1791+ ## ` v8 .startHeapProfile ([options]) `
17921792
17931793<!-- YAML
17941794added: REPLACEME
17951795-->
17961796
1797- * {Object}
1798-
1799- A frozen object containing constants used with [` v8 .startHeapProfile ()` ][].
1800-
1801- The following constants are available:
1802-
1803- | Constant | Description |
1804- | ------------------------------------------------ | --------------------------------------------------- |
1805- | ` SAMPLING_NO_FLAGS ` | No flags. |
1806- | ` SAMPLING_FORCE_GC ` | Force garbage collection before taking the profile. |
1807- | ` SAMPLING_INCLUDE_OBJECTS_COLLECTED_BY_MAJOR_GC ` | Include objects collected by major GC. |
1808- | ` SAMPLING_INCLUDE_OBJECTS_COLLECTED_BY_MINOR_GC ` | Include objects collected by minor GC. |
1809-
1810- These constants can be combined using bitwise OR to pass as the ` flags`
1811- parameter.
1812-
1813- ## ` v8 .startHeapProfile ([sampleInterval[, stackDepth[, flags]]])`
1814-
1815- <!-- YAML
1816- added: REPLACEME
1817- -->
1818-
1819- * ` sampleInterval` {number} The average sampling interval in bytes.
1820- **Default:** ` 524288 ` (512 KiB).
1821- * ` stackDepth` {integer} The maximum stack depth for samples.
1822- **Default:** ` 16 ` .
1823- * ` flags` {integer} Flags to control sampling behavior. Use constants from
1824- [` v8 .heapProfilerConstants ` ][]. Multiple flags can be combined with bitwise
1825- OR. **Default:** ` v8 .heapProfilerConstants .SAMPLING_NO_FLAGS ` .
1797+ * ` options` {Object}
1798+ * ` sampleInterval` {number} The average sampling interval in bytes.
1799+ **Default:** ` 524288 ` (512 KiB).
1800+ * ` stackDepth` {integer} The maximum stack depth for samples.
1801+ **Default:** ` 16 ` .
1802+ * ` forceGC` {boolean} Force garbage collection before taking the profile.
1803+ **Default:** ` false ` .
1804+ * ` includeObjectsCollectedByMajorGC` {boolean} Include objects collected
1805+ by major GC. **Default:** ` false ` .
1806+ * ` includeObjectsCollectedByMinorGC` {boolean} Include objects collected
1807+ by minor GC. **Default:** ` false ` .
18261808* Returns: {SyncHeapProfileHandle}
18271809
18281810Starting a heap profile then return a ` SyncHeapProfileHandle` object.
@@ -1848,28 +1830,26 @@ With custom parameters:
18481830
18491831` ` ` cjs
18501832const v8 = require (' node:v8' );
1851- const { heapProfilerConstants } = v8;
1852-
1853- const handle = v8 .startHeapProfile (
1854- 1024 ,
1855- 8 ,
1856- heapProfilerConstants .SAMPLING_FORCE_GC |
1857- heapProfilerConstants .SAMPLING_INCLUDE_OBJECTS_COLLECTED_BY_MAJOR_GC ,
1858- );
1833+
1834+ const handle = v8 .startHeapProfile ({
1835+ sampleInterval: 1024 ,
1836+ stackDepth: 8 ,
1837+ forceGC: true ,
1838+ includeObjectsCollectedByMajorGC: true ,
1839+ });
18591840const profile = handle .stop ();
18601841console .log (profile);
18611842` ` `
18621843
18631844` ` ` mjs
18641845import v8 from ' node:v8' ;
1865- const { heapProfilerConstants } = v8;
1866-
1867- const handle = v8 .startHeapProfile (
1868- 1024 ,
1869- 8 ,
1870- heapProfilerConstants .SAMPLING_FORCE_GC |
1871- heapProfilerConstants .SAMPLING_INCLUDE_OBJECTS_COLLECTED_BY_MAJOR_GC ,
1872- );
1846+
1847+ const handle = v8 .startHeapProfile ({
1848+ sampleInterval: 1024 ,
1849+ stackDepth: 8 ,
1850+ forceGC: true ,
1851+ includeObjectsCollectedByMajorGC: true ,
1852+ });
18731853const profile = handle .stop ();
18741854console .log (profile);
18751855` ` `
@@ -1908,8 +1888,6 @@ console.log(profile);
19081888[` serializer .transferArrayBuffer ()` ]: #serializertransferarraybufferid-arraybuffer
19091889[` serializer .writeRawBytes ()` ]: #serializerwriterawbytesbuffer
19101890[` settled` callback]: #settledpromise
1911- [` v8 .heapProfilerConstants ` ]: #v8heapprofilerconstants
1912- [` v8 .startHeapProfile ()` ]: #v8startheapprofilesampleinterval-stackdepth-flags
19131891[` v8 .stopCoverage ()` ]: #v8stopcoverage
19141892[` v8 .takeCoverage ()` ]: #v8takecoverage
19151893[` vm .Script ` ]: vm.md#new-vmscriptcode-options
0 commit comments