node js - Node js v8 - node - node js tutorial - webnode




What is V8 ?

  • V8 is an open source JavaScript engine developed by the Chromium project for the Google Chrome web browser.
  • It is written in C++. Now a days, it is used in many projects such as Couchbase, MongoDB and Node.js.
 nodejs v8 image

Learn Node js - node js Tutorial - nodejs v8 image - node - Node js Examples

V8 in Node.js ?

  • The Node.js V8 module represents interfaces and event specific to the version of V8.
  • It provides methods to get information about heap memory through v8.getHeapStatistics() and v8.getHeapSpaceStatistics() methods.
  • To use this module, you need to use require('v8').
const v8 = require('v8');  

Node.js v8.getHeapStatistics() Example:

  • The v8.getHeapStatistics() method returns statistics about heap such as total heap size, used heap size, heap size limit, total available size etc.

Node JS Tutorial File: v8-example1.js

const v8 = require('v8');  
console.log(v8.getHeapStatistics());  

Node JS Output :

 node.js v8 example1

Learn Node js - node js Tutorial -node.js v8 example1 - node - Node js Examples

Node.js v8.getHeapSpaceStatistics() Example

  • The v8.getHeapSpaceStatistics() returns statistics about heap space.
  • It returns an array of 5 objects: new space, old space, code space, map space and large object space.
  • Each object contains information about space name, space size, space used size, space available size and physical space size.

Node JS Tutorial File: v8-example2.js

const v8 = require('v8');  
console.log(v8.getHeapSpaceStatistics());  

Node JS Output :

 node.js v8 example2

Learn Node js - node js Tutorial - node.js v8 example2 - node - Node js Examples

Related nodejs article tags - node js - node js tutorial - node js examples

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. You can 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.

This wikitechy technological portal provides you whole lot of information related to the topics such as mongodb tutorial , what is node js , express js tutorial , node js tutorial pdf , learn node js , node js tutorial for beginners , node js tutorial w3schools , node js express , javascript for beginners , node js express tutorial , node js tutorial point , node js book , node js server , note js , node js mongodb , what is node js used for , why node js , node tutorial , node js basics , tutorialspoint node js , node express , node js sample application , nodeschool , node js for beginners , express tutorial , node js application , use of node js , npm tutorial , node js org , node js training , node js online training , node js tutorial beginner , how to use node js , node js hello world , express node js , node js mongodb tutorial , nodejs http , why use node js

Related Searches to Node.js V8