Uh oh!
There was an error while loading. Please reload this page.
Reduce memory consumption for failed connections - #113
Conversation
kelunik
commented
Sep 1, 2017
This should rather be fixed in |
valga
commented
Sep 1, 2017
@kelunik Even if it will be fixed in |
valga
commented
Sep 2, 2017
Ok, I found a problem with |
clue
commented
Sep 4, 2017
Thanks for filing this ticket and the elaborate discussion in the related tickets! 👍 I've updated to title to reflect the current state of the discussion and IMO it makes sense to get this in as-is. To sum this up, this component does not "leak" any memory, but reducing the memory consumption by reducing the number of circular dependencies is certainly a good thing 👍 |
At first, some background on this. I have a long-running script that maintains persistence on some connections, so if connection was reset, it retries with an exponential backoff. Sometimes it runs without issues and sometimes it eats a lot of memory and even becomes unresponsive and is getting killed by watchdog. Apart from maintaining connections, my script just reads incoming data and writes it into a file, so there are no memory leaks in my code.
After a research, I found that timed out connections produce a lot of garbage, that can be cleaned only with GC. Here is a test scenario:
Result:
After doing more research, I found that is caused by promise cancellation: the more
->then()you have on cancellable promise, the more garbage it will leave after cancellation. So I tweaked code a bit and got this result:Now we have 30% less garbage to collect. There is still a room for improvement, but it needs to be done with the Promise component.