andywer / leakage

🐛 Memory leak testing for node.
1.58k stars 52 forks source link

How to catch a probable false alarm #25

Closed diorahman closed 7 years ago

diorahman commented 7 years ago

This is actually a really nice module. Thanks!

I have set up a small experiment here: https://github.com/diorahman/send However, I'm not sure if the http.Agent with keepAlive: true is supposed to be leaking all the time.

If I set the keepAlive as https://github.com/diorahman/send/blob/master/fetch.js#L12 it leaks, however if I set it false it doesn't.

What do you think?

Thanks!

andywer commented 7 years ago

Hey @diorahman.

Yeah, that makes sense. The connection pool will keep growing until it reaches some limit, thus growing the heap.

I think it should not leak if you .destroy() the agent at the end of the iteration. Or maybe you can create the agent before starting to iterate, set it's maxFreeSockets option to a low value and open connections until the pool is filled before you start iterating.

andywer commented 7 years ago

Might be worth adding to #19

diorahman commented 7 years ago

Yes, you're right. I need to set the maxFreeSockets to a small number to let it pass. Thanks!