![]() |
VOOZH | about |
The v8.getHeapStatistics() method is an inbuilt application programming interface of the v8 module which is used to get statistics about heap derived from the v8 version.
Syntax:
v8.getHeapStatistics();
Parameters: This method does not have any parameters.
Return Value: This method returns an object that contains statistics about version 8 heap. The returned object usually contains an array, that consists of following fields:
Below examples illustrate the use of v8.getHeapStatistics() method in Node.js.
Example 1: Filename: index.js
Run index.js file using the following command:
node index.js
Output:
{ total_heap_size: 6537216,
total_heap_size_executable: 1048576,
total_physical_size: 6537216,
total_available_size: 1520717240,
used_heap_size: 4199600,
heap_size_limit: 1526909922,
malloced_memory: 8192,
peak_malloced_memory: 406408,
does_zap_garbage: 0 }
Example 2: Filename: index.js
Run index.js file using the following command:
node index.js
Output:
Heap Statistics are : total_heap_size:6537216 used_heap_size:4200640 heap_size_limit:1526909922 does_zap_garbage:0
Reference: https://nodejs.org/api/v8.html#v8_v8_getheapstatistics