Browse Source
src: extend `HeapStatistics` with new fields
src: Add does_zap_garbage, malloced_memory and
peak_malloced_memory to v8 HeapStatistics
Following https://github.com/nodejs/code-and-learn/issues/56 I
have exposed does_zap_garbage to HeapStatistics.
The other fields, malloced_memory and peak_malloced_memory don't
seem to be in the current version of v8 in master.
PR-URL: https://github.com/nodejs/node/pull/8610
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
v7.x
Gareth Ellis
8 years ago
committed by
Anna Henningsen
No known key found for this signature in database
GPG Key ID: D8B9F5AEAE84E4CF
4 changed files with
27 additions and
3 deletions
doc/api/v8.md
lib/v8.js
src/node_v8.cc
test/parallel/test-v8-stats.js
@ -22,6 +22,15 @@ Returns an object with the following properties:
* `total_available_size` {number}
* `used_heap_size` {number}
* `heap_size_limit` {number}
* `malloced_memory` {number}
* `peak_malloced_memory` {number}
* `does_zap_garbage` {number}
`does_zap_garbage` is a 0/1 boolean, which signifies whether the `--zap_code_space`
option is enabled or not. This makes V8 overwrite heap garbage with a bit
pattern. The RSS footprint (resident memory set) gets bigger because it
continuously touches all heap pages and that makes them less likely to get
swapped out by the operating system.
For example:
@ -32,7 +41,10 @@ For example:
total_physical_size: 7326976,
total_available_size: 1152656,
used_heap_size: 3476208,
heap_size_limit: 1535115264
heap_size_limit: 1535115264,
malloced_memory: 16384,
peak_malloced_memory: 1127496,
does_zap_garbage: 0
}
```
@ -25,6 +25,9 @@ const kTotalPhysicalSizeIndex = v8binding.kTotalPhysicalSizeIndex;
const kTotalAvailableSize = v8binding . kTotalAvailableSize ;
const kUsedHeapSizeIndex = v8binding . kUsedHeapSizeIndex ;
const kHeapSizeLimitIndex = v8binding . kHeapSizeLimitIndex ;
const kDoesZapGarbageIndex = v8binding . kDoesZapGarbageIndex ;
const kMallocedMemoryIndex = v8binding . kMallocedMemoryIndex ;
const kPeakMallocedMemoryIndex = v8binding . kPeakMallocedMemoryIndex ;
// Properties for heap space statistics buffer extraction.
const heapSpaceStatisticsBuffer =
@ -49,7 +52,10 @@ exports.getHeapStatistics = function() {
'total_physical_size' : buffer [ kTotalPhysicalSizeIndex ] ,
'total_available_size' : buffer [ kTotalAvailableSize ] ,
'used_heap_size' : buffer [ kUsedHeapSizeIndex ] ,
'heap_size_limit' : buffer [ kHeapSizeLimitIndex ]
'heap_size_limit' : buffer [ kHeapSizeLimitIndex ] ,
'malloced_memory' : buffer [ kMallocedMemoryIndex ] ,
'peak_malloced_memory' : buffer [ kPeakMallocedMemoryIndex ] ,
'does_zap_garbage' : buffer [ kDoesZapGarbageIndex ]
} ;
} ;
@ -28,7 +28,10 @@ using v8::Value;
V ( 2 , total_physical_size , kTotalPhysicalSizeIndex ) \
V ( 3 , total_available_size , kTotalAvailableSize ) \
V ( 4 , used_heap_size , kUsedHeapSizeIndex ) \
V ( 5 , heap_size_limit , kHeapSizeLimitIndex )
V ( 5 , heap_size_limit , kHeapSizeLimitIndex ) \
V ( 6 , malloced_memory , kMallocedMemoryIndex ) \
V ( 7 , peak_malloced_memory , kPeakMallocedMemoryIndex ) \
V ( 8 , does_zap_garbage , kDoesZapGarbageIndex )
# define V(a, b, c) +1
static const size_t kHeapStatisticsPropertiesCount =
@ -5,7 +5,10 @@ var v8 = require('v8');
var s = v8 . getHeapStatistics ( ) ;
var keys = [
'does_zap_garbage' ,
'heap_size_limit' ,
'malloced_memory' ,
'peak_malloced_memory' ,
'total_available_size' ,
'total_heap_size' ,
'total_heap_size_executable' ,