Demo project to demonstrate how to debug Out of Memory issues, and more in general performance bottlenecks.
During this demo, you'll see how to debug the heap "Out of Memory" issue in Javascript, leveraging Node.js features and using the open-source tools available in this repository ⬇️
To deep dive into the OoM issues topic and how to use the right tools to properly debug and fix the "JavaScript heap out of memory" issue, please refer to the talk I presented at the JavaScript Global Summit ⬇️
Feel free also to check out the answers I shared during the Q&A session ⬇️
Follow those commands:
npm i
npm run start
Now you can retrieve data from the endpoints:
# output => {"result":100}
curl 'http://127.0.0.1:3000/list?size=100'
# output => {"result":200}
curl 'http://127.0.0.1:3000/list?size=100'
# output => {"result":300}
curl 'http://127.0.0.1:3000/list?size=100'
# output => {"sum":42}
curl 'http://127.0.0.1:3000/sum?a=12&b=30'
# output => {"value":"42!"}
curl 'http://127.0.0.1:3000/print?val=42'
- Run
npm run start - Open the
Activity monitor(or the equivalent for your OS) and be sure to show theMemorytab and to filter bynode - Run
npm run stress - See how the
Memoryvalue changes over time
- Run
npm run inspect - Open a new Chrome tab
chrome://inspect/#devices - Click
Inspecton theRemote Targetpointing tosrc/index.js - On the
Memorytab, selectAllocation samplingand clickStart - Run
npm run stress - Once finished, click
Stopon the DevTools opened window - Analyze the results, in particular the
Total Size
Run npm run profile on one window (wait for 🔥 Profiling message), then npm run stress on another one:
Once the stress command is done, stop the profile command (with CTRL-C).
You should see the message 🔥 Flamegraph generated in and a new browser tab should be opened with a similar result to what you can see in the ./out folder: