AndreasMadsen / trace

Creates super long stack traces
https://trace.js.org
MIT License
194 stars 18 forks source link

Memory leak #45

Open Sprit3Dan opened 5 years ago

Sprit3Dan commented 5 years ago

Memory leak!

Hello! Not sure if it is done on purpose, and it is by-design, but I encountered a huge memory leak using your library with express.js.

I created a tiny PoC for you to check it out. https://github.com/Sprit3Dan/mem-leak

The way it could be reproduces is to make the callback for the express path asynchronous by adding the async keyword.

Here are the charts for heap used per ~1k queries.

If you add the library:

image

If not:

image

Guess many people could be stuck at this situation, when using you lib. Hope you find this ticket useful :)

AndreasMadsen commented 5 years ago

@Sprit3Dan Thanks you so much. Similar issues have been reported before, but I couldn't get a simple test case.

AndreasMadsen commented 5 years ago

@Sprit3Dan Just to be safe, what version of node.js are you using?

Sprit3Dan commented 5 years ago

@AndreasMadsen, I'm using v8.12.0 LTS

cspotcode commented 5 years ago

I see the memory leak on v8.12.0 but not on v10.11.0. This might be a node bug, considering that async_hooks was a preview feature in node 8.