-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce memory consumption for failed connections #113
Conversation
This should rather be fixed in |
@kelunik Even if it will be fixed in |
Ok, I found a problem with |
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 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.