Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I worry about high RSS in node if the heaptotal / heapused is low?

So I'm a starting programmer and I honestly can't find any information about what node's rss means. Everything just says its the total amount of memory allocated to the process. great! so is that a problem?

I'm writing a small discord bot in node and I noticed my rss going all over the place.

45.5 MB used for shard 1 (10.1 MB HeapUsed, 16.9 MB HeapTotal)
37.2 MB used for shard 1 (7.1 MB HeapUsed, 9.6 MB HeapTotal)
75.3 MB used for shard 1 (7.2 MB HeapUsed, 9.6 MB HeapTotal)

These are measurements about 5 seconds apart after starting up the process. It stays at that ~75MB mark.

I'm wondering if I should actually worry about this memory usage or if it's totally fine. Say I run this program on a host with only 2GB of ram. Would having an RSS of 1800MB be bad or would it just cap itself there and only improve the heapused/heaptotal?

Also is there any way to check what the process is assigning memory to in node?

My question really just is, Should I worry about the RSS or should I just ignore it and only look at the heap?

like image 976
Daaku Avatar asked Oct 24 '25 18:10

Daaku


1 Answers

RSS is the total portion of the memory allocated for the running node process at hand system wise.

This means that even though heap portions of the memory are low, total rss could grow arbitrarily high unless the system where the node process resides decides to free it -possibly because it's running out of memory for other processes-

Most of the time, this is a "normal" behaviour of node, although some discussions have marked this as "a possible hidden memory leak" within node itself.

When the time comes, system should signal the process to free the unused memory that has being "reserved" for node.

Other times though, rss can grow bigger due to binary dependencies on your project. Let's say, those having memory leaks within them, system wouldn't be able to free that memory when the system requires so.

TL;DR

Unless you're having an specific problem regarding the rss memory space allocation -in which case, you'll definitely know-, don't panic about this behaviour, as most of the time the underlying system should take care of it.

Pay attention to your binary dependencies though. Those will not show on the heap size reported by V8's engine, and in case of a memory leak within them, that portion of memory will no be able to be freed given the time has come.

source

like image 191
Ian Sebastian Avatar answered Oct 26 '25 09:10

Ian Sebastian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!