![]() |
VOOZH | about |
The v8.getHeapSpaceStatistics() method is an inbuilt application programming interface of the v8 module which is used to get statistics about heap space derived from the v8 version.
Syntax:
v8.getHeapSpaceStatistics();
Parameters: This method does not have any parameters.
Return Value: This method returns an object that contains statistics about version 8 heap space. The returned object usually contains an array of multiple elements, where each element consists of the following fields:
Example 1: The below example illustrates the use of the v8.getHeapSpaceStatistics() method in Node.js.
Filename: index.js
Run the index.js file using the following command:
node index.js
Output:
[ { space_name: 'read_only_space',
space_size: 524288,
space_used_size: 35208,
space_available_size: 480376,
physical_space_size: 524288 },
{ space_name: 'new_space',
space_size: 2097152,
space_used_size: 975376,
space_available_size: 55792,
physical_space_size: 2097152 },
{ space_name: 'old_space',
space_size: 2330624,
space_used_size: 2272448,
space_available_size: 184,
physical_space_size: 2330624 },
{ space_name: 'code_space',
space_size: 1048576,
space_used_size: 571968,
space_available_size: 0,
physical_space_size: 1048576 },
{ space_name: 'map_space',
space_size: 536576,
space_used_size: 344784,
space_available_size: 0,
physical_space_size: 536576 },
{ space_name: 'large_object_space',
space_size: 0,
space_used_size: 0,
space_available_size: 1520180736,
physical_space_size: 0 } ]
Example 2: The below example illustrates the use of the v8.getHeapSpaceStatistics() method in Node.js.
Filename: index.js
Run the index.js file using the following command:
node index.js
Output: 👁 Image
Reference: https://nodejs.org/api/v8.html#v8_v8_getheapspacestatistics