mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
bafd5444ab
Sincef59ec2abee
, `BaseObject` instances were tracked in heap snapshots through their associated `CleanupHookCallback`s which were stored on the `Environment`; however, this is inaccurate, because: - Edges in heap dumps imply a keeps-alive relationship, but cleanup hooks do not keep the `BaseObject`s that they point to alive. - It loses information about whether `BaseObject` instances are GC roots: Even weak `BaseObject`s are now, practically speaking, showing up as hanging off a GC root when that isn’t actually the case (e.g. in the description of nodejs/node#33468). Thus, this is a partial revert off59ec2abee
. Refs: https://github.com/nodejs/node/issues/33468 Refs: https://github.com/nodejs/node/pull/27018 PR-URL: https://github.com/nodejs/node/pull/33809 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
25 lines
849 B
JavaScript
25 lines
849 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
// This tests that Environment is tracked in heap snapshots.
|
|
|
|
require('../common');
|
|
const { validateSnapshotNodes } = require('../common/heap');
|
|
|
|
// This is just using ContextifyScript as an example here, it can be replaced
|
|
// with any BaseObject that we can easily instantiate here and register in
|
|
// cleanup hooks.
|
|
// These can all be changed to reflect the status of how these objects
|
|
// are captured in the snapshot.
|
|
const context = require('vm').createScript('const foo = 123');
|
|
|
|
validateSnapshotNodes('Node / Environment', [{
|
|
children: [
|
|
{ node_name: 'Node / cleanup_hooks', edge_name: 'cleanup_hooks' },
|
|
{ node_name: 'process', edge_name: 'process_object' },
|
|
{ node_name: 'Node / IsolateData', edge_name: 'isolate_data' },
|
|
]
|
|
}]);
|
|
|
|
console.log(context); // Make sure it's not GC'ed
|