Node.js v8.getHeapStatistics() Method Last Updated : 01 Nov, 2022 Comments Improve Suggest changes Like Article Like Report 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: total_heap_size: A number, signifies total heap size.total_heap_size_executable: A number, signifies total executable heap size.total_physical_size: A number, signifies total physical size.total_available_size: A number, signifies the total available size.used_heap_size: A number, signifies used heap size.heap_size_limit: A number, signifies heap size limit.malloced_memory: A number, signifies malloced memory.peak_malloced_memory: A number, signifies maximum malloced memory.does_zap_garbage: A number, specifically a boolean, signifies whether the --zap_code_space option is enabled or not.number_of_native_contexts: A number, signifies a number of native contexts or the top-level contexts currently active. Memory leakage might be indicated by measuring the increment of this number over time.number_of_detached_contexts: A number, signifies a number of detached contexts or contexts that were detached and not yet garbage collected. Memory leakage might be indicated if it has non zero value. Below examples illustrate the use of v8.getHeapStatistics() method in Node.js. Example 1: Filename: index.js javascript // Accessing v8 module const v8 = require('v8'); // Calling v8.getHeapStatistics() console.log(v8.getHeapStatistics()); 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 javascript // Accessing v8 module const v8 = require('v8'); // Calling v8.getHeapStatistics() stats = v8.getHeapStatistics(); console.log("Heap Statistics are :"); console.log("total_heap_size:"+stats['total_heap_size']); console.log("used_heap_size:"+stats['used_heap_size']); console.log("heap_size_limit:"+stats['heap_size_limit']); console.log("does_zap_garbage:"+stats['does_zap_garbage']); 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 Comment More infoAdvertise with us Next Article Node.js v8.serialize() Method V vyer Follow Improve Article Tags : Web Technologies Node.js Node.js-V8-Module Similar Reads V8 Module APIsNode.js v8.cachedDataVersionTag() MethodThe v8.cachedDataVersionTag() method is an inbuilt application programming interface of the v8 module which is used to get the version tag derived from the v8 version. Syntax: v8.cachedDataVersionTag(); Parameters: This method does not have any parameters. Return Value: This method returns the versi 1 min read Node.js v8.getHeapSpaceStatistics() MethodThe 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 r 2 min read Node.js v8.getHeapStatistics() MethodThe 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 2 min read Serialization APINode.js v8.serialize() MethodThe v8.serialize() method is an inbuilt application programming interface of the v8 module which is used to serialize any type of data into a buffer using default serializer. Syntax: v8.serialize(value); Parameters: This method one parameter as described below and mentioned above. value: This is a r 2 min read Node.js v8.deserialize() MethodThe v8.deserialize() method is an inbuilt application programming interface of the v8 module which is used to deserialize a buffered data into JS value using default deserializer. Syntax: v8.deserialize( buffer ); Parameters: This method accepts one parameter as mentioned above and described below: 1 min read v8.Serializer MethodsNode.js v8.Serializer.writeHeader() MethodThe v8.Serializer.writeHeader() method is an inbuilt application programming interface of the v8.Serializer module, is used to write out a header, that contains the serialization format version. Syntax: v8.Serializer.writeHeader(); Parameters: This method does not have any parameters. Return Value: 1 min read Node.js v8.Serializer.writeValue() MethodThe v8.Serializer.writeValue() method is an inbuilt application programming interface of the v8.Serializer module which is used to write the serialized data of JS value to the internal buffer. Syntax: v8.Serializer.writeValue(Value); Parameters: This method one parameter as described below and menti 1 min read Node.js v8.Serializer.releaseBuffer() MethodThe v8.Serializer.releaseBuffer() method is an inbuilt application programming interface of the v8.Serializer module which is used to get content of the internal buffer. Syntax: v8.Serializer.releaseBuffer(); Parameters: This method does not have any parameters. Return Value: This method returns the 2 min read Node.js v8.Serializer.writeUint32() MethodThe v8.Serializer.writeUint32() method is an inbuilt application programming interface of the v8.Serializer module, which is used to write the raw 32-bit integer value to the internal buffer. For use inside of custom serializer._writeHostObject(). Syntax: v8.Serializer.writeUint32( value ); Paramete 2 min read Node.js v8.Serializer.writeUint64() MethodThe v8.Serializer.writeUint64() method is an inbuilt application programming interface of the v8.Serializer module which is used to write a raw 64-bit integer value to the internal buffer by splitting into high and low 32-bit integers. For use inside of custom serializer._writeHostObject()method . S 2 min read Node.js v8.Serializer.writeDouble() MethodThe v8.Serializer.writeDouble() method is an inbuilt application programming interface of the v8.Serializer module which is used to write a JS number value to the internal buffer. For use inside of custom serializer._writeHostObject(). Syntax: v8.Serializer.writeDouble( Value ); Parameters: This met 1 min read Node.js v8.Serializer.writeRawBytes() MethodThe v8.Serializer.writeRawBytes() method is an inbuilt application programming interface of the v8.Serializer module which is used to write a raw buffer data to the internal buffer. For use inside of custom serializer._writeHostObject(). Syntax: v8.Serializer.writeRawBytes( Buffer ); Parameters: Thi 1 min read v8.Deserializer MethodsNode.js v8.Deserializer.readHeader() MethodThe v8.Deserializer.readHeader() method is an inbuilt application programming interface of the v8.Deserializer module which is used to read the header and validate it, to ensure that contains a valid serialization format version. Syntax: v8.Deserializer.readHeader(); Parameters: This method does not 1 min read Node.js v8.Deserializer.readValue() MethodThe v8.Deserializer.readValue() method is an inbuilt application programming interface of the v8.Deserializer module which is used to read the JS value from serialized data as present in a buffer. Syntax: v8.Deserializer.readValue(); Parameters: This method does not accept any parameters. Return Val 1 min read Node.js v8.Deserializer.readUint32() MethodThe v8.Deserializer.readUint32() method is an inbuilt application programming interface of the v8.Deserializer module which is used to read a raw 32-bit unsigned integer value from the buffer. For use inside of custom Deserializer._readHostObject(). Syntax: v8.Deserializer.readUint32(); Parameters: 1 min read Node.js v8.Deserializer.readUint64() MethodThe v8.Deserializer.readUint64() method is an inbuilt application programming interface of the v8.Deserializer module which is used to read a raw 64-bit unsigned integer value from the buffer as an array of 32-bit integers, higher and lower 32-bits separated. For use inside of custom Deserializer._r 2 min read Node.js v8.Deserializer.readRawBytes() MethodThe v8.Deserializer.readRawBytes() method is an inbuilt application programming interface of the v8.Deserializer module which is used to read a raw buffer data from deserializer's internal buffer of the given length. For use inside of custom Deserializer._readHostObject(). Syntax: v8.Deserializer.re 2 min read Like