File tree 4 files changed +25
-4
lines changed
4 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -131,13 +131,24 @@ Returns an object with the following properties:
131
131
* ` malloced_memory ` {number}
132
132
* ` peak_malloced_memory ` {number}
133
133
* ` does_zap_garbage ` {number}
134
+ * ` number_of_native_contexts ` {number}
135
+ * ` number_of_detached_contexts ` {number}
136
+
134
137
135
138
` does_zap_garbage ` is a 0/1 boolean, which signifies whether the
136
139
` --zap_code_space ` option is enabled or not. This makes V8 overwrite heap
137
140
garbage with a bit pattern. The RSS footprint (resident memory set) gets bigger
138
141
because it continuously touches all heap pages and that makes them less likely
139
142
to get swapped out by the operating system.
140
143
144
+ ` number_of_native_contexts ` The value of native_context is the number of the
145
+ top-level contexts currently active. Increase of this number over time indicates
146
+ a memory leak.
147
+
148
+ ` number_of_detached_contexts ` The value of detached_context is the number
149
+ of contexts that were detached and not yet garbage collected. This number
150
+ being non-zero indicates a potential memory leak.
151
+
141
152
<!-- eslint-skip -->
142
153
``` js
143
154
{
@@ -149,7 +160,9 @@ to get swapped out by the operating system.
149
160
heap_size_limit: 1535115264 ,
150
161
malloced_memory: 16384 ,
151
162
peak_malloced_memory: 1127496 ,
152
- does_zap_garbage: 0
163
+ does_zap_garbage: 0 ,
164
+ number_of_native_contexts: 1 ,
165
+ number_of_detached_contexts: 0
153
166
}
154
167
```
155
168
Original file line number Diff line number Diff line change @@ -109,7 +109,9 @@ const {
109
109
kSpaceSizeIndex,
110
110
kSpaceUsedSizeIndex,
111
111
kSpaceAvailableSizeIndex,
112
- kPhysicalSpaceSizeIndex
112
+ kPhysicalSpaceSizeIndex,
113
+ kNumberOfNativeContextsIndex,
114
+ kNumberOfDetachedContextsIndex
113
115
} = internalBinding ( 'v8' ) ;
114
116
115
117
const kNumberOfHeapSpaces = kHeapSpaces . length ;
@@ -139,7 +141,9 @@ function getHeapStatistics() {
139
141
'heap_size_limit' : buffer [ kHeapSizeLimitIndex ] ,
140
142
'malloced_memory' : buffer [ kMallocedMemoryIndex ] ,
141
143
'peak_malloced_memory' : buffer [ kPeakMallocedMemoryIndex ] ,
142
- 'does_zap_garbage' : buffer [ kDoesZapGarbageIndex ]
144
+ 'does_zap_garbage' : buffer [ kDoesZapGarbageIndex ] ,
145
+ 'number_of_native_contexts' : buffer [ kNumberOfNativeContextsIndex ] ,
146
+ 'number_of_detached_contexts' : buffer [ kNumberOfDetachedContextsIndex ]
143
147
} ;
144
148
}
145
149
Original file line number Diff line number Diff line change @@ -52,7 +52,9 @@ using v8::Value;
52
52
V (5 , heap_size_limit, kHeapSizeLimitIndex ) \
53
53
V (6 , malloced_memory, kMallocedMemoryIndex ) \
54
54
V (7 , peak_malloced_memory, kPeakMallocedMemoryIndex ) \
55
- V (8 , does_zap_garbage, kDoesZapGarbageIndex )
55
+ V (8 , does_zap_garbage, kDoesZapGarbageIndex ) \
56
+ V (9 , number_of_native_contexts, kNumberOfNativeContextsIndex ) \
57
+ V (10 , number_of_detached_contexts, kNumberOfDetachedContextsIndex )
56
58
57
59
#define V (a, b, c ) +1
58
60
static const size_t kHeapStatisticsPropertiesCount =
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ const keys = [
8
8
'does_zap_garbage' ,
9
9
'heap_size_limit' ,
10
10
'malloced_memory' ,
11
+ 'number_of_detached_contexts' ,
12
+ 'number_of_native_contexts' ,
11
13
'peak_malloced_memory' ,
12
14
'total_available_size' ,
13
15
'total_heap_size' ,
You can’t perform that action at this time.
0 commit comments