@@ -44,6 +44,13 @@ class NodeBIO;
44
44
* // Node name and size comes from the MemoryInfoName and SelfSize of
45
45
* // AnotherRetainerClass
46
46
* tracker->TrackField("another_retainer", another_retainer_);
47
+ *
48
+ * // Add non_pointer_retainer as a separate node into the graph
49
+ * // and track its memory information recursively.
50
+ * // Note that we need to make sure its size is not accounted in
51
+ * // ExampleRetainer::SelfSize().
52
+ * tracker->TrackField("non_pointer_retainer", &non_pointer_retainer_);
53
+ *
47
54
* // Specify node name and size explicitly
48
55
* tracker->TrackFieldWithSize("internal_member",
49
56
* internal_member_.size(),
@@ -60,9 +67,12 @@ class NodeBIO;
60
67
* return "ExampleRetainer";
61
68
* }
62
69
*
63
- * // Or use SET_SELF_SIZE(ExampleRetainer)
70
+ * // Classes that only want to return its sizeof() value can use the
71
+ * // SET_SELF_SIZE(Class) macro instead.
64
72
* size_t SelfSize() const override {
65
- * return sizeof(ExampleRetainer);
73
+ * // We need to exclude the size of non_pointer_retainer so that
74
+ * // we can track it separately in ExampleRetainer::MemoryInfo().
75
+ * return sizeof(ExampleRetainer) - sizeof(NonPointerRetainerClass);
66
76
* }
67
77
*
68
78
* // Note: no need to implement these two methods when implementing
@@ -71,8 +81,10 @@ class NodeBIO;
71
81
* v8::Local<v8::Object> WrappedObject() const override {
72
82
* return node::PersistentToLocal(wrapped_);
73
83
* }
84
+ *
74
85
* private:
75
- * AnotherRetainerClass another_retainer_;
86
+ * AnotherRetainerClass* another_retainer_;
87
+ * NonPointerRetainerClass non_pointer_retainer;
76
88
* InternalClass internal_member_;
77
89
* std::vector<uv_async_t> vector_;
78
90
* node::Persistent<Object> target_;
0 commit comments