v8: add GCProfiler support for erm

PR-URL: https://github.com/nodejs/node/pull/61191
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
This commit is contained in:
Ilyas Shabi authored and Antoine du Hamel committed 2026-01-22 14:46:34 +01:00
1 parent ade4fc2338
commit c75ad3d87d
3 files changed
+40 -1

No files matched your search

+10 -1
View File
@@ -1471,6 +1471,7 @@ added:
-->
Create a new instance of the `v8.GCProfiler` class.
This API supports `using` syntax.
### `profiler.start()`
@@ -1490,7 +1491,7 @@ added:
- v18.15.0
-->
Stop collecting GC data and return an object.The content of object
Stop collecting GC data and return an object. The content of object
is as follows.
```json
@@ -1575,6 +1576,14 @@ setTimeout(() => {
}, 1000);
```
### `profiler[Symbol.dispose]()`
<!-- YAML
added: REPLACEME
-->
Stop collecting GC data, and discard the profile.
## Class: `SyncCPUProfileHandle`
<!-- YAML
+4
View File
@@ -488,6 +488,10 @@ class GCProfiler {
return JSONParse(data);
}
}
[SymbolDispose]() {
this.stop();
}
}
module.exports = {
@@ -0,0 +1,26 @@
'use strict';
require('../common');
const assert = require('assert');
const { GCProfiler } = require('v8');
{
const profiler = new GCProfiler();
profiler.start();
const result = profiler[Symbol.dispose]();
assert.strictEqual(result, undefined);
assert.strictEqual(profiler.stop(), undefined);
}
{
const profiler = new GCProfiler();
profiler.start();
profiler[Symbol.dispose]();
// Repeat invocations should not throw
profiler[Symbol.dispose]();
assert.strictEqual(profiler.stop(), undefined);
}