NodeJS
Memory Management &
Memory Leak Detection
By Sina Sharafzadeh
Nodejs Memory stuff
Nodejs Garbage Collection
Resident Set
Code Segment
Stack Segment
Old Pointer Space ...
Heap Size
Call Stack
…
Why my app use this much memory?
It’s really under the load…(cpu intensive call stack!)
Garbage collection not running yet
Memory leaks
Let’s allocate some memory
Examples ...
How much memory we can use?
Current limit is near 1.76GB
Let’s reach it and see examples …
How we can prevent reaching the limits?
Call the gc , when and how(pros and cons)?
Find the leakages
Scale your app
Optimize your code
Why we should use that much memory , a cpu intensive task🤔?
We can change the limits 😁😁
Take care of why your memory growth
Let’s create some leakages
Let’s create some leakages ...
Logical leakages
New instance leakages
...
Chrome profiler detailed
Attach to your node app
At start with arguments
At runtime (kill -SIGUSR1 + node-inspect)
To running instance on server
Some Suggestions