summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Klauke <romaaan.git@gmail.com>2015-08-11 20:06:41 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2015-08-11 22:51:50 +0200
commitad7f74453dfe4b13738e13eaf039e73c3daf1fd8 (patch)
treefc0a7fe7183ccc6d80cce5f1cbded965681143be
parentae05807f0472fbe73b96660a93ae4b4924eb67ce (diff)
downloadandroid-node-v8-ad7f74453dfe4b13738e13eaf039e73c3daf1fd8.tar.gz
android-node-v8-ad7f74453dfe4b13738e13eaf039e73c3daf1fd8.tar.bz2
android-node-v8-ad7f74453dfe4b13738e13eaf039e73c3daf1fd8.zip
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-git-mirror@0a1352a7 PR-URL: https://github.com/nodejs/io.js/pull/2348 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
-rw-r--r--doc/api/v8.markdown1
-rw-r--r--lib/v8.js2
-rw-r--r--src/node_v8.cc5
-rw-r--r--test/parallel/test-v8-stats.js1
4 files changed, 7 insertions, 2 deletions
diff --git a/doc/api/v8.markdown b/doc/api/v8.markdown
index cedd5c86d9..4caf6ebcd4 100644
--- a/doc/api/v8.markdown
+++ b/doc/api/v8.markdown
@@ -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
}
diff --git a/lib/v8.js b/lib/v8.js
index f25814bab3..acadfa64e0 100644
--- a/lib/v8.js
+++ b/lib/v8.js
@@ -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;
@@ -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]
};
diff --git a/src/node_v8.cc b/src/node_v8.cc
index 0a3e6e7633..db492e3d1a 100644
--- a/src/node_v8.cc
+++ b/src/node_v8.cc
@@ -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 =
diff --git a/test/parallel/test-v8-stats.js b/test/parallel/test-v8-stats.js
index e48c1d7036..fc4a6df30f 100644
--- a/test/parallel/test-v8-stats.js
+++ b/test/parallel/test-v8-stats.js
@@ -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',