mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 17:57:53 +00:00

v8.getHeapSpaceStatistics() now includes new_large_object_space
in its results. Update test-v8-stats.js to account for this.
Refs: a383aa33e5
PR-URL: https://github.com/nodejs/node/pull/21983
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const v8 = require('v8');
|
|
|
|
const s = v8.getHeapStatistics();
|
|
const keys = [
|
|
'does_zap_garbage',
|
|
'heap_size_limit',
|
|
'malloced_memory',
|
|
'peak_malloced_memory',
|
|
'total_available_size',
|
|
'total_heap_size',
|
|
'total_heap_size_executable',
|
|
'total_physical_size',
|
|
'used_heap_size'];
|
|
assert.deepStrictEqual(Object.keys(s).sort(), keys);
|
|
keys.forEach(function(key) {
|
|
assert.strictEqual(typeof s[key], 'number');
|
|
});
|
|
|
|
|
|
const expectedHeapSpaces = [
|
|
'new_space',
|
|
'old_space',
|
|
'code_space',
|
|
'map_space',
|
|
'new_large_object_space',
|
|
'large_object_space',
|
|
'read_only_space'
|
|
];
|
|
const heapSpaceStatistics = v8.getHeapSpaceStatistics();
|
|
const actualHeapSpaceNames = heapSpaceStatistics.map((s) => s.space_name);
|
|
assert.deepStrictEqual(actualHeapSpaceNames.sort(), expectedHeapSpaces.sort());
|
|
heapSpaceStatistics.forEach((heapSpace) => {
|
|
assert.strictEqual(typeof heapSpace.space_name, 'string');
|
|
assert.strictEqual(typeof heapSpace.space_size, 'number');
|
|
assert.strictEqual(typeof heapSpace.space_used_size, 'number');
|
|
assert.strictEqual(typeof heapSpace.space_available_size, 'number');
|
|
assert.strictEqual(typeof heapSpace.physical_space_size, 'number');
|
|
});
|