Possible memory leak in nsqjs writer
See original GitHub issueHi,
I’m using NodeJS 11.5.0 did a simple benchmark of the nsqjs Writer (v0.12.0) and found a possible memory leak, possibly the same kind as in https://github.com/dudleycarr/nsqjs/issues/211 which was related to the nsqjs Reader. You’ll find attached the app.js
script I used for testing as well as the package.json
and test.json
file. Basically, it uses nsqjs Writer as a middleware for Koa (code was mostly taken from https://github.com/dudleycarr/nsqjs/issues/202#issuecomment-346075638). For the benchmark, I simply used a while true
loop with curl, sending a small json content as POST data to the Koa endpoint (example: while true; do curl -XPOST -d @test.json http://127.0.0.1:3000/test -H 'Accept: application/json' -H 'Content-Type: application/json'; done
).
Below is the result of the heap profiling. Heap snapshots were taken every 10 minutes. As you can see, the heap grows quite rapidly (from ~20 to ~140 MB). Apparently, this seems related to the debug module.
To confirm this, I did something really dirty but effective. I commented out every mention to the debug module in nsqdconnection.js
and writer.js
and went through the same process. Heap profiling result is below. In this case, the heap is stable.
I’m far from being a NodeJS guru though 😉. So if I’m missing something important or if my testing code is buggy, don’t hesitate to tell me. Still, it really looks like the same behavior as in https://github.com/dudleycarr/nsqjs/issues/211
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
After further investigation, I do not believe my memory leak was caused the
nsqjs:Writer
class. However, thank you so much for your responsiveness @dudleycarr.@ilikegolf I’ll take a look this week to see if I can reproduce the issue.