mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
`MemoryTracker::AddNode(const CppgcMixin*)` allocates a `MemoryRetainerNode` that only stands in for the wrapper's JS node while its `MemoryInfo()` runs; unlike the other node kinds it is not handed to the `EmbedderGraph`, and nothing freed it. Every heap snapshot (or other `BuildEmbedderGraph` call) leaked one node per live `vm.Script` or `vm` context. Keep the placeholders in the tracker and free them with it, and make the already-seen path in `Track(const CppgcMixin*)` add its edge to the wrapper's JS node like the first visit does, so the graph never refers to a placeholder. Refs: https://github.com/nodejs/node/pull/56534 Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com> PR-URL: https://github.com/nodejs/node/pull/65793 Reviewed-By: James M Snell <jasnell@gmail.com>
16 lines
559 B
JavaScript
16 lines
559 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const { validateByRetainingPath } = require('../common/heap');
|
|
const vm = require('vm');
|
|
const source = 'const foo = 123';
|
|
const script = new vm.Script(source);
|
|
const context = vm.createContext();
|
|
|
|
validateByRetainingPath('Node / ContextifyScript', [
|
|
{ node_name: '(shared function info)' }, // This is the UnboundScript referenced by ContextifyScript.
|
|
{ edge_name: 'script' },
|
|
{ edge_name: 'source', node_type: 'string', node_name: source },
|
|
]);
|
|
|
|
console.log(script, context); // Keep the script and context alive.
|