How to get the total memory and free memory of a system using Node.js?



How to get the total memory and free memory of a system using Node.js? | ninjasquad

In today’s article, we will discuss how to get the total memory and available memory of the system using NodeJS.

To get the total memory of the system

To get the total memory of the operating system using NodeJS, you can use totalmem() method from the os module in Node.js.

Note that this method returns total memory in bytes.

// import os module
const os = require("os");

// check the total memory of the system
const totalMemory = os.totalmem();

To get the free memory available in the system

To get the free memory available in the system you can use freemem() method from the os module in NodeJS.

const os = require("os");

// check free memory of the system
const freeMemory = os.freemem();
Feel free to share if you found this useful

Editorial Staff

Editorial Staff at Tutsplanet is a dedicated team to write various tutorials about subjects like Programming, Technology and Operating Systems.



Source: Internet

Leave a Comment

We are offering free coding tuts

X