Skip to content

Commit ccf12df

Browse files
r-52rvagg
authored andcommitted
src: add total_available_size to v8 statistics
v8 introduced the new flag `total_available_size` in version 4.4 and upwards. This flag is now available on `v8.getHeapStatistics` with the name `total_available_size`. It contains the total available heap size of v8. Introduced with commit: v8/v8@0a1352a7 PR-URL: #2348 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent cc46d3b commit ccf12df

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

doc/api/v8.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Returns an object with the following properties
1515
total_heap_size: 7326976,
1616
total_heap_size_executable: 4194304,
1717
total_physical_size: 7326976,
18+
total_available_size: 1152656,
1819
used_heap_size: 3476208,
1920
heap_size_limit: 1535115264
2021
}

lib/v8.js

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const heapStatisticsBuffer =
2222
const kTotalHeapSizeIndex = v8binding.kTotalHeapSizeIndex;
2323
const kTotalHeapSizeExecutableIndex = v8binding.kTotalHeapSizeExecutableIndex;
2424
const kTotalPhysicalSizeIndex = v8binding.kTotalPhysicalSizeIndex;
25+
const kTotalAvailableSize = v8binding.kTotalAvailableSize;
2526
const kUsedHeapSizeIndex = v8binding.kUsedHeapSizeIndex;
2627
const kHeapSizeLimitIndex = v8binding.kHeapSizeLimitIndex;
2728

@@ -34,6 +35,7 @@ exports.getHeapStatistics = function() {
3435
'total_heap_size': buffer[kTotalHeapSizeIndex],
3536
'total_heap_size_executable': buffer[kTotalHeapSizeExecutableIndex],
3637
'total_physical_size': buffer[kTotalPhysicalSizeIndex],
38+
'total_available_size': buffer[kTotalAvailableSize],
3739
'used_heap_size': buffer[kUsedHeapSizeIndex],
3840
'heap_size_limit': buffer[kHeapSizeLimitIndex]
3941
};

src/node_v8.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ using v8::Value;
2626
V(0, total_heap_size, kTotalHeapSizeIndex) \
2727
V(1, total_heap_size_executable, kTotalHeapSizeExecutableIndex) \
2828
V(2, total_physical_size, kTotalPhysicalSizeIndex) \
29-
V(3, used_heap_size, kUsedHeapSizeIndex) \
30-
V(4, heap_size_limit, kHeapSizeLimitIndex)
29+
V(3, total_available_size, kTotalAvailableSize) \
30+
V(4, used_heap_size, kUsedHeapSizeIndex) \
31+
V(5, heap_size_limit, kHeapSizeLimitIndex)
3132

3233
#define V(a, b, c) +1
3334
static const size_t kHeapStatisticsPropertiesCount =

test/parallel/test-v8-stats.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var v8 = require('v8');
66
var s = v8.getHeapStatistics();
77
var keys = [
88
'heap_size_limit',
9+
'total_available_size',
910
'total_heap_size',
1011
'total_heap_size_executable',
1112
'total_physical_size',

0 commit comments

Comments
 (0)