diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2019-03-27 22:46:03 +0300 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2019-04-04 06:09:29 +0300 |
commit | f59ec2abee82f22822b7b3231ca2056fc028a279 (patch) | |
tree | 3be1fa8fa8b2be425ecc29254b9e8fcb1df111af /src/base_object.h | |
parent | ceb80f415798818a059051537132bba691c68db7 (diff) |
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 `BaseObject`s 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.
PR-URL: https://github.com/nodejs/node/pull/27018
Refs: https://github.com/nodejs/node/issues/26776
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/base_object.h')
-rw-r--r-- | src/base_object.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/base_object.h b/src/base_object.h index 091c3d5af01..f1c666224f0 100644 --- a/src/base_object.h +++ b/src/base_object.h @@ -86,7 +86,6 @@ class BaseObject : public MemoryRetainer { private: v8::Local<v8::Object> WrappedObject() const override; - bool IsRootNode() const override; static void DeleteMe(void* data); // persistent_handle_ needs to be at a fixed offset from the start of the @@ -95,7 +94,7 @@ class BaseObject : public MemoryRetainer { // position of members in memory are predictable. For more information please // refer to `doc/guides/node-postmortem-support.md` friend int GenDebugSymbols(); - friend class Environment; + friend class CleanupHookCallback; Persistent<v8::Object> persistent_handle_; Environment* env_; |