Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: add total_available_size to v8 statistics #2348

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/api/v8.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Returns an object with the following properties
total_heap_size: 7326976,
total_heap_size_executable: 4194304,
total_physical_size: 7326976,
total_available_size: 1152656,
used_heap_size: 3476208,
heap_size_limit: 1535115264
}
Expand Down
2 changes: 2 additions & 0 deletions lib/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const heapStatisticsBuffer =
const kTotalHeapSizeIndex = v8binding.kTotalHeapSizeIndex;
const kTotalHeapSizeExecutableIndex = v8binding.kTotalHeapSizeExecutableIndex;
const kTotalPhysicalSizeIndex = v8binding.kTotalPhysicalSizeIndex;
const kTotalAvailableSize = v8binding.kTotalAvailableSize;
const kUsedHeapSizeIndex = v8binding.kUsedHeapSizeIndex;
const kHeapSizeLimitIndex = v8binding.kHeapSizeLimitIndex;

Expand All @@ -34,6 +35,7 @@ exports.getHeapStatistics = function() {
'total_heap_size': buffer[kTotalHeapSizeIndex],
'total_heap_size_executable': buffer[kTotalHeapSizeExecutableIndex],
'total_physical_size': buffer[kTotalPhysicalSizeIndex],
'total_available_size': buffer[kTotalAvailableSize],
'used_heap_size': buffer[kUsedHeapSizeIndex],
'heap_size_limit': buffer[kHeapSizeLimitIndex]
};
Expand Down
5 changes: 3 additions & 2 deletions src/node_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ using v8::Value;
V(0, total_heap_size, kTotalHeapSizeIndex) \
V(1, total_heap_size_executable, kTotalHeapSizeExecutableIndex) \
V(2, total_physical_size, kTotalPhysicalSizeIndex) \
V(3, used_heap_size, kUsedHeapSizeIndex) \
V(4, heap_size_limit, kHeapSizeLimitIndex)
V(3, total_available_size, kTotalAvailableSize) \
V(4, used_heap_size, kUsedHeapSizeIndex) \
V(5, heap_size_limit, kHeapSizeLimitIndex)

#define V(a, b, c) +1
static const size_t kHeapStatisticsPropertiesCount =
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-v8-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var v8 = require('v8');
var s = v8.getHeapStatistics();
var keys = [
'heap_size_limit',
'total_available_size',
'total_heap_size',
'total_heap_size_executable',
'total_physical_size',
Expand Down