Hi Guest 1 HomePage 1 Jobs 1 WalkIn 1Articles  

 :) Latest Topic
Node.js Tutorial
Parts of Node.js
Features of Node.js
Install Node.js Windows
Install Node.js Linux
Node.js First Example
Node.js Console
Node.js JavaScript Learn
Node.js REPL
Node.js NPM
Node.js CL Options1
Node.js CL Option2
Node.js Globals
Node.js OS
Node.js Timer
Node.js Errors
Node.js DNS
Node.js Net
Node.js Crypto
Node.js TLS/SSL
Node.js Debugger
Node.js Process
Node.js Process Example
Node.js Process Example2
Node.js Child Process
Child Process EXEC
Child Process SPAWN
Child Process Fork
Node.js Buffers
Node.js Streams
Node.js Reading Stream
Node.js Writing Stream
Node.js Piping Stream
Node.js Chaining Streams
Node.js File System Part1
Node.js File System Part2
Node.js File System Part3
Node.js Path
Node.js StringDecoder
Node.js Query String
Node.js ZLIB
Node.js Assertion
Node.js V8
Node.js Callbacks
Node.js Events
Node.js Punycode
Node.js TTY
Node.js Web Module
Node.js Upload Files
Node.js Email Send
Node.js BuiltIn Modules
Node.js Assert Code
Node.js Assert Function
Node.js console.time()
Node.js console.table()
Node.js DNS Code
Node.js cipher.final()
Node.js URL.hash API
Node.js URL.host API
Node.js URL.origin API
Node.js MySQL
Folders in Node.js
Folders Node.js part3
Rename Folder Node.js
Remove Folder Node.js
 


  

 
Node.js V8
Question Posted on 06 Apr 2024

Home >> Tutorial >> Node.js Tutorial >> Node.js V8


Node.js V8

Node.js V8 (What is V8)


When we say about the V8, it is an open source JavaScript engine developed by the chromium project for the Google Chrome web browser. And it is written in C++. And now a days, this is being used by many projects such as MongoDB, Node.js and Couchbase.


V8 in Node.js


The Node.js V8 module represents interfaces and event specific to the version of V8. And this will provides methods to get information about heap memory through v8.getHeapStatistics() and v8.getHeapSpaceStatistics() methods.

And to use this module, you need to use require('v8').

const v8 = require('v8');




Node.js V8 output

Node.js v8.getHeapStatistics() Example


The Node.js v8.getHeapStatistics() method return statistics about the heap such as total heap size, heap size limit, used heap size, total available size etc.

File: v8-example1.js

const v8 = require('v8');

console.log(v8.getHeapStatistics());


Node.js v8.getHeapSpaceStatistics() Example


The Node.js v8.getHeapSpaceStatistics() method returns statistics about the heap space. And this will returns an array of 5 objects:-
(1)New space
(2)Old space
(3)Code space
(4)Map space
(5)large object space
Here each object contains information about the space name, space size, space available size, physical space size and space used size.

File: v8-example2.js

const v8 = require('v8');

console.log(v8.getHeapSpaceStatistics());



Node.js V8 output

Memory limit of V8 in Node.js


Currently, by default v8 has a memory limit of 512mb on 32-bit and 1gb on 64-bit systems. And we can also raise the limit by setting --max-old-space-size to a maximum of ~1gb for 32-bit and ~1.7gb for 64-bit systems. But it is recommended to split your single process into several workers if you are hitting memory limits.





Other Important Questions
Parts of Node.js
Install Node.js Linux
Node.js First Example
Node.js Globals
Node.js DNS







 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |