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 systemTo 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
Did this post help you?
Tutsplanet brings in-depth and easy tutorials to understand even for beginners. This takes a considerable amount of work. If this post helps you, please consider supporting us as a token of appreciation:
- Just want to thank us? Buy us a Coffee
- May be another day? Shop on Amazon using our links.
Your prices won't change but we get a small commission.
Leave a Reply