Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Issues with Node 10 #2512

Closed
nimit95 opened this issue Mar 5, 2020 · 11 comments
Closed

Memory Issues with Node 10 #2512

nimit95 opened this issue Mar 5, 2020 · 11 comments

Comments

@nimit95
Copy link

nimit95 commented Mar 5, 2020

  • 10.16.0:
  • CentOS:
  • 4 Gb memory:
    My memory Usage looks like this before usage -->
    {"rss":33607680,"heapTotal":16498688,"heapUsed":12249688,"external":104174}

My memory Usage looks like this after usage --> {"rss":3519221760,"heapTotal":194232320,"heapUsed":183946368,"external":4255851993}}

High external memory usage. GC trigger is not helping. How to debug what is taking the external memory. Heap snapshots(Chrome) are only giving heap space used.

The memory graph is:-
Screenshot 2020-02-29 at 12 09 17 PM

Can't figure out the reason. How to monitor the External memory and figure out the leak? Any help or leads

@mhdawson
Copy link
Member

mhdawson commented Mar 6, 2020

My suggestion would be to try to use valgrind as outlined here: https://github.com/nodejs/node/blob/master/doc/guides/investigating_native_memory_leak.md

It can give you information about native memory.

@mhdawson
Copy link
Member

mhdawson commented Mar 6, 2020

The other thing to note is that RSS will not necessarily go down just because there is free memory in the heap.

@nimit95
Copy link
Author

nimit95 commented Mar 6, 2020

I don't understand it, initially, node process was taking say 400 Mb of memory, then RSS started taking 3.5 GB of RAM. Is there a reason why it wouldn't give memory back to the OS?
If an object in RSS(external) is taking that much space I should be able to see it somewhere.

@gireeshpunathil
Copy link
Member

here is the explanation for the said rss behavior: nodejs/node#21266 (comment)

btw, looking at your data, looks like your heap has grown as well, so it may be that there are JS objects getting piled up in the heap?

{"rss":33607680,  "heapTotal":16498688, "heapUsed":12249688, "external":104174}
{"rss":3519221760,"heapTotal":194232320,"heapUsed":183946368,"external":4255851993}

@nimit95
Copy link
Author

nimit95 commented Mar 7, 2020

I agree heap has increased as well, that may be because I store some objects in the memory. Even still the heap memory increase like ~10x to 1.5 GB still manageable. But the external memory increase from 0.15 MB to 4.5 Gb(~50000x). That's is what for me is the low hanging fruit to fix first.

@nimit95
Copy link
Author

nimit95 commented Mar 7, 2020

I understood the point that RSS will be reserved with the process. But in my case, OOM killer is killing the process that means the process must be asking for more memory. Will try Valgrind to figure out what is causing memory issues.

@gireeshpunathil
Copy link
Member

@nimit95 -

that may be because I store some objects in the memory.

do you have any insights into what type of objects are going there? I am asking this because, the external memory typically contain backend C++ objects that provide low level capability to the JS objects, so knowing what goes into JS heap will help us to know what to expect in external. Then using valgrind we could validate the theory.

@nimit95
Copy link
Author

nimit95 commented Mar 8, 2020

So basically heap objects have plain javascript objects, couple of arrays. What I suspect is happening is when I am writing large chunks into WebSockets, both heap and external memory increase. But I am not able to prove or disprove this theory.

@gireeshpunathil
Copy link
Member

@nimit95 -

But I am not able to prove or disprove this theory.

your theory may be correct. Let us look at the valgrind report, which may give more conclusive hints.

@gireeshpunathil
Copy link
Member

@nimit95 - is this still an issue?

@gireeshpunathil
Copy link
Member

inactive, closing. feel free to re-open if it is outstanding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants