VOOZH about

URL: https://www.geeksforgeeks.org/node-js/node-js-os-totalmem-method/

⇱ Node.js os.totalmem() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Node.js os.totalmem() Method

Last Updated : 28 Apr, 2025

The os.totalmem() method is an inbuilt application programming interface of the os module which is used to get the amount of total system memory in bytes. 

Syntax:

os.totalmem()

Parameters: This method does not accept any parameters. 

Return Value: This method returns an integer value that specifies the amount of total system memory in bytes. 

Example 1: The below example illustrates the use of os.totalmem() method in Node.js: 

Output:

8502722560

Example 2: The below example illustrates the use of the os.totalmem() method in Node.js: 

Output:

Total memory: 7GB 940MB 848KB and 0Bytes

Example 3: The below example illustrates the use of the os.totalmem() method in Node.js: 

Output:

Free Memory 4161896448 Bytes out of 8502722560 Bytes

Note: The above program will compile and run by using the node index.js command.

Reference: https://nodejs.org/api/os.html#os_os_totalmem

Comment

Explore