| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e8352ff commit e5289d1
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -173,9 +173,15 @@ void BaseObjectList::Cleanup() { | |||
| 173 | 173 | } | |
| 174 | 174 | } | |
| 175 | 175 | ||
| 176 | - void BaseObjectList::MemoryInfo(node::MemoryTracker* tracker) const { | ||
| 176 | + void BaseObjectList::MemoryInfo(MemoryTracker* tracker) const { | ||
| 177 | 177 | for (auto bo : *this) { | |
| 178 | - if (bo->IsDoneInitializing()) tracker->Track(bo); | ||
| 178 | + if (bo->IsDoneInitializing()) { | ||
| 179 | + // TODO(addaleax): Add weak edges instead of no edges once | ||
| 180 | + // https://github.com/v8/v8/commit/e37cadf1143a8c5bbe44c0408186b5a26cc23863 | ||
| 181 | + // is available for us | ||
| 182 | + tracker->Track( | ||
| 183 | + bo, bo->persistent().IsWeak() ? MemoryTracker::kWeakEdge : nullptr); | ||
| 184 | + } | ||
| 179 | 185 | } | |
| 180 | 186 | } | |
| 181 | 187 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,10 @@ void CppgcWrapperList::MemoryInfo(MemoryTracker* tracker) const { | |||
| 16 | 16 | for (auto node : *this) { | |
| 17 | 17 | CppgcMixin* ptr = node->persistent.Get(); | |
| 18 | 18 | if (ptr != nullptr) { | |
| 19 | - tracker->Track(ptr); | ||
| 19 | + // TODO(addaleax): Add weak edges instead of no edges once | ||
| 20 | + // https://github.com/v8/v8/commit/e37cadf1143a8c5bbe44c0408186b5a26cc23863 | ||
| 21 | + // is available for us | ||
| 22 | + tracker->Track(ptr, MemoryTracker::kWeakEdge); | ||
| 20 | 23 | } | |
| 21 | 24 | } | |
| 22 | 25 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -335,11 +335,25 @@ function validateByRetainingPath(...args) { | |||
| 335 | 335 | return validateByRetainingPathFromNodes(nodes, ...args); | |
| 336 | 336 | } | |
| 337 | 337 | ||
| 338 | + function getRetainingNodes(startingNode, filter) { | ||
| 339 | + const seen = new Set(); | ||
| 340 | + function listNodes(node) { | ||
| 341 | + if (!filter(node) || seen.has(node)) return; | ||
| 342 | + seen.add(node); | ||
| 343 | + for (const edge of node.incomingEdges) { | ||
| 344 | + listNodes(edge.from); | ||
| 345 | + } | ||
| 346 | + } | ||
| 347 | + listNodes(startingNode); | ||
| 348 | + return [...seen]; | ||
| 349 | + } | ||
| 350 | + | ||
| 338 | 351 | module.exports = { | |
| 339 | 352 | recordState, | |
| 340 | 353 | validateSnapshotNodes, | |
| 341 | 354 | validateByRetainingPath, | |
| 342 | 355 | validateByRetainingPathFromNodes, | |
| 343 | 356 | getHeapSnapshotOptionTests, | |
| 344 | 357 | createJSHeapSnapshot, | |
| 358 | + getRetainingNodes, | ||
| 345 | 359 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | 4 | const common = require('../common'); | |
| 5 | 5 | const assert = require('assert'); | |
| 6 | - const { validateByRetainingPath, validateByRetainingPathFromNodes } = require('../common/heap'); | ||
| 6 | + const { validateByRetainingPath, validateByRetainingPathFromNodes, getRetainingNodes } = require('../common/heap'); | ||
| 7 | 7 | const zlib = require('zlib'); | |
| 8 | 8 | ||
| 9 | 9 | // Before zlib stream is created, no ZlibStream should be created. | |
@@ -27,6 +27,18 @@ const gzip = zlib.createGzip(); | |||
| 27 | 27 | assert.strictEqual(withMemory.length, 0); | |
| 28 | 28 | } | |
| 29 | 29 | ||
| 30 | + { | ||
| 31 | + // Assert that the `ZlibStream` has no unexpected connections | ||
| 32 | + // to other `Node / ...` nodes. | ||
| 33 | + const contexts = validateByRetainingPath('Node / ZlibContext', []); | ||
| 34 | + assert.deepStrictEqual( | ||
| 35 | + getRetainingNodes(contexts[0], (node) => node.name?.startsWith('Node /')) | ||
| 36 | + .map((node) => node.name).sort(), [ | ||
| 37 | + 'Node / ZlibContext', | ||
| 38 | + 'Node / ZlibStream', | ||
| 39 | + ]); | ||
| 40 | + } | ||
| 41 | + | ||
| 30 | 42 | // After zlib stream is written, zlib_memory should be created. | |
| 31 | 43 | gzip.write('hello world', common.mustCall(() => { | |
| 32 | 44 | validateByRetainingPath('Node / ZlibStream', [ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments