Skip to content

src: implement MemoryRetainer in Environment

This allows us to track the essentially-global objects in Environment in the heap snapshot. Note that this patch only tracks the fields that can be tracked correctly. There are still several types of fields that cannot be tracked:

  • v8::Data including v8::Private, v8::ObjectTemplate etc.
  • Internal types that do not implement MemoryRetainer yet
  • STL containers with MemoryRetainer* inside
  • STL containers with numeric types inside that should not have their nodes elided e.g. numeric keys in maps.

The BaseObjects are now no longer globals. They are tracked as arguments in CleanupHookCallbacks referenced by the Environment node. This model is closer to how their lifetime is managed internally.

To track the per-environment strong persistent properties, this patch divides them into those that are also v8::Value and those that are just v8::Data. The values can be tracked by the current memory tracker while the data cannot.

This patch also implements the MemoryRetainer interface in several internal classes so that they can be tracked in the heap snapshot.

Comparison against the heap snapshot generated before this patch

Screen Shot 2019-03-30 at 3 01 20 PM

The base objects are now tracked like this (instead of being globals on their own)

Screen Shot 2019-03-30 at 3 45 34 PM

Refs: https://github.com/nodejs/node/issues/26776

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Merge request reports

Loading