Skip to content

high rss and steady and low heap usage #12805

Closed

Description

@terrywh

Version: Node v7.8.0
Platform: Linux (CentOS 7.0 x64)

image

I am using --inspect to get get heap snap shots. in the heap snap shots, it show a memory usage of only 27MB, but when seeing in the system it show a large rss usage.

message from console:
image
snap from top command:
image
heap snapshots:
image

am i missing something ? or is this suppose to be? this project is using some third party (C++) modules.

i try to add --max_old_space_size=128 options but i got no luck, it seems this options has not been working at all ( i also tried options that using '-' insdead of '_' --max-old-space-size=128, it seems to be also not working);

Activity

  1. added
    inspectorIssues and PRs related to the V8 inspector protocol.
    memoryIssues and PRs related to Node.js memory management or memory footprint.
    on May 3, 2017
  2. mscdex commented on May 3, 2017

    @mscdex
    Contributor

    @terrywh Can you reproduce it without the compiled addons? It could be that the addons you're using do not let V8 know about memory they have allocated/deallocated (via AdjustAmountOfExternalAllocatedMemory())?

  3. bnoordhuis commented on May 3, 2017

    @bnoordhuis
    Member

    Do you have transparent huge pages enabled? Try turning it off, see #11077.

  4. terrywh commented on May 3, 2017

    @terrywh
    Author

    @mscdex i'm using https://github.com/Blizzard/node-rdkafka, i will try to see if i can reproduce without it.
    @bnoordhuis already turned off :
    image

  5. dlueth commented on May 17, 2017

    @dlueth

    Same Problem here on EBS t2.micro as well as t2.medium instances. "max_old_space_size" and the likes had no influence and disabling transparent huge pages did not help either.

    I stripped down the app to do exactly nothing but still, RSS constantly grows while Heap stays a flat line.

  6. dlueth commented on May 18, 2017

    @dlueth

    In addition to my previous post: checked this behaviour​ on 7.10.0, 7.6.0 and the only working fix was to go back to 6.10.3

  7. terrywh commented on May 18, 2017

    @terrywh
    Author

    @dlueth "do exactly nothing" so what does it do specifically?

  8. dlueth commented on May 18, 2017

    @dlueth

    @terrywh Sorry for having been a bit unspecific: Nothing left but an idle loop, just to keep the process running

  9. terrywh commented on May 18, 2017

    @terrywh
    Author

    @dlueth maybe you can give us some code to reproduce this problem? my problem seems to be caused by the c++ module.

  10. dlueth commented on May 18, 2017

    @dlueth

    @terrywh If I find the time tonight I will try to prepare something

  11. dlueth commented on May 19, 2017

    @dlueth

    Will take some more time to prepare an example of our problem - will report back!

  12. bnoordhuis commented on Jun 26, 2017

    @bnoordhuis
    Member

    Closing due to inactivity. Can reopen if needed.

  13. terrywh commented on Jun 26, 2017

    @terrywh
    Author

    I file another issue on the c++ module Blizzard/node-rdkafka, and will report back if i got anything concrete.

  14. owenallenaz commented on Jul 16, 2017

    @owenallenaz

    @dlueth Could you possibly test on Node 7.4.0? We are facing a similar large RSS, no heap growth issue, and I swear it used to work on 7.4.0. If you're unable to reproduce on that version, then it might narrow the window of what changed that caused it. Or maybe it's a 3rd party package... not sure yet.

  15. dlueth commented on Jul 17, 2017

    @dlueth

    @owenallenaz Will see what I can do to test this and report back!

  16. dlueth commented on Jul 17, 2017

    @dlueth

    @owenallenaz Did not help in our case, switching to 7.4.0 shows the same behaviour regarding large RSS but constant heap as later versions do

  17. bam-tbf commented on Feb 3, 2018

    @bam-tbf

    @dlueth I am seeing similar issues even on node 8.9.3 and 9.5.0 streaming image files from an image server through a zip archiving routine then by express down to the user. I have tried destroying every stream created manually and calling garbage collection manually, but the RSS space is high, never decreases while heap stays relatively constant and low. Thank you for any update. This data graphed here covers the period of manual destroying and garbage collection for example.

    screen shot 2018-02-02 at 5 45 25 pm

  18. dlueth commented on Feb 6, 2018

    @dlueth

    @bam-tbf In our case the issue is not solved but the overall situation improved, at least with 8.9.4. There still is a memory leak burried somewhere but it is now within acceptable limits, restarting our instances once a week is sufficient so far.

    One of the causes was an external script we depended on that, in the meantime, fixed its leaks (and we got finally rid of in the end anyway) but the guys behind it mentioned that there still are some potential leaks left within node itself.

  19. Restuta commented on Aug 17, 2018

    @Restuta

    @dlueth if it's a memory leak shouldn't it consume heap space?

  20. dlueth commented on Aug 18, 2018

    @dlueth

    @Restuta it normally should but somehow node seemed to eventually loose track of it and assume it as non-heap

  21. akaJes commented on Aug 20, 2018

    @akaJes

    try to use the jemalloc library - it prevent the RSS grownig

    #21973

  22. hakimelek commented on Oct 31, 2020

    @hakimelek

    We are still experiencing the same issue in v12.16.3, any leads about how to track down what is causing RSS to grow? No luck with the devtools since it's reporting only the heap memory.

  23. gireeshpunathil commented on Oct 31, 2020

    @gireeshpunathil
    Member

    @hakimelek - what is your system's memory configuration? I am suspecting something similar to #31641 , wherein a large demand of memory in the process that occurred and satisfied in the past, but never released back due to the fact that the system did not want those back as it has ample free memory.

  24. hakimelek commented on Nov 1, 2020

    @hakimelek

    @gireeshpunathil Yes there are 4 processes running on an 8Gb RAM. When inspecting the processes memory I see both the Virtual Size and Resident Size trending up under load, these are retrieved in New Relic. These boxes in productions are running in v10.21.0.

    I have tried to reproduce the same locally even after upgrading to v12.16.3 and tap on process.memoryUsage() directly and I noticed that only RSS gets bigger but the heapUsed remain constant overtime. It is running on a 16Gb RAM machine.

    After a couple of heap snapshots in production, I am wondering if that the memory growing perceived by the system is not caused by the heap memory and I am not sure now what tools can I used to get insights around the RSS memory.

    11/2 Update:

    This is the behavior I see in the application locally
    image

    I would assume that every time GC is kicked in and heap memory drops, RSS should drop as well. Am I missing anything?

  25. gireeshpunathil commented on Nov 6, 2020

    @gireeshpunathil
    Member

    thanks for the charts. As mentioned in the referenced issue, the rss memory does not automatically come down in response to memory free-up from the process, instead only in response to memory demands from the rest of the system (other processes wanting to use memory). So even if it shows high, you can consider that those are not really used in your application.

    I would assume that every time GC is kicked in and heap memory drops, RSS should drop as well. Am I missing anything?

    gc does not lead to reduction in rss. Instead, reduction of valid objects in the heap.

    My summary: unless the rss growth in unbounded and leading up to memory exhaustion, you don't have to worry about the current rss value.

    Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    inspectorIssues and PRs related to the V8 inspector protocol.memoryIssues and PRs related to Node.js memory management or memory footprint.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions