You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@jeremyvergnas See #11Memory leak in _contexts which discusses it. Contexts are removed on async_hook's destroy event, although it appears sometimes to take a while for some resources to be garbage collected.
That said, there was some additional work added in node 9.3.0 for destroy event in garbage collected AsyncResources, although I think the use of AsyncResources by embedder libs is small but hopefully growing.
It should be noted that usage of an HTTP agent with maxSockets: Infinity, maxFreeSockets: 256 can also result in the same situation: A lot of sockets will be created which results in a lot of cls-hooked context objects. The socket objects will only start to get GCed at a later point.
This becomes especially problematic when adding (potentially) large objects to the CLS context.
In our specific case, we are adding additional cleanup logic on top of cls-hooked to reduce the impact and likeliness of problems.
I did a quick test with 100 concurrent HTTP requests for like a couple of minutes watching the memory usage, did not see any major leakage on the heap_used so far. :)
Hi there,
I was wondering whether the
Map
of contexts would be automatically cleaned at some point or should we usedestroy
to do that?It could lead to performance issue as the Map is becoming bigger and bigger.
Thanks for your work!
The text was updated successfully, but these errors were encountered: