This is the total memory allocated for the process, including heap, stack, and the memory used by the actual executable code.
It represents the total memory being used by the Node.js process in the system’s RAM.
Use Case:
rss helps to determine the overall memory footprint of the application in the operating system.
It’s useful for monitoring how much system memory (RAM) the application is using, which is critical when deploying to environments with limited resources.
2. heapTotal
Value in this case: 1826816 bytes (~1.74 MB)
What it is:
The total size of the memory heap that has been allocated for JavaScript objects.
The heap is the area of memory where JavaScript objects, variables, and functions are stored when they are dynamically created.
Use Case:
heapTotal shows how much memory the V8 JavaScript engine has reserved for object allocation.
This value increases as the application requires more memory, and the garbage collector may step in when it needs to free up some of this memory.
3. heapUsed
Value in this case: 650472 bytes (~0.62 MB)
What it is:
This shows how much of the heap is currently being used to store JavaScript objects.
It’s the portion of heapTotal that contains active objects. When objects are no longer used, they will be garbage collected, freeing up space in the heap.
Use Case:
heapUsed is an important indicator of memory usage by the application.
Monitoring heapUsed over time can help identify memory leaks—if this value keeps growing without being reduced by garbage collection, the application might have a memory leak.
4. external
Value in this case: 49879 bytes (~49 KB)
What it is:
This is memory used by C++ objects bound to JavaScript objects.
It’s memory allocated outside of the JavaScript heap (managed by V8) but still associated with the Node.js process.
Use Case:
external memory is usually used by libraries that handle things like native bindings, buffers, or external modules that interact with system-level resources.
Useful when you need to monitor memory usage for native modules or when using features like Buffer in Node.js.
5. arrayBuffers
Value in this case: 9386 bytes (~9 KB)
What it is:
This represents the memory allocated for ArrayBuffer and SharedArrayBuffer objects, which are used to store raw binary data.
Use Case:
arrayBuffers is important if the application is working with large binary data (e.g., reading files, network requests, or handling multimedia files).
It helps monitor memory allocated to raw buffers and can be useful when debugging performance issues related to buffer usage.
Summary of Use Cases:
rss: Monitors overall memory footprint on the system. Useful for tracking total resource consumption.
heapTotal: Monitors how much memory has been allocated for JavaScript objects. Useful for understanding how much space is available in the heap.
heapUsed: Monitors how much of the allocated heap is actually in use by active JavaScript objects. Helpful for detecting memory leaks.
external: Tracks memory usage outside the V8 heap, important when working with native modules or buffers.
arrayBuffers: Tracks memory used by binary data, crucial for applications dealing with buffers and raw data.