Use Set instead of Array for Condition @waiting queue to avoid memory leak #186
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #176
We found that calling
dequeue
on instances ofQueue
(andLimitedQueue
) inside aTask.with_timeout
block inside a loop will result in fibers accumulating in the@waiting
list for the Queue in the absence of any other fiber signalling theQueue
, leading to a memory leak.Our short term fix for this was just to manually
signal
theQueue
whenever the timeout was reached, but this only works where a single fibre is waiting on the queue with a timeout in a loop.Switching to using a
Set
instead of anArray
to hold the list of waiting fibres resolves the core issue. I don't think this will break anything as I can't really see a use case for having the same fibre in the@waiting
list multiple times.Keen for input on what tests might be appropriate for this, if any. Is suppose the main thing is that this change does not break the existing test suite.
Types of Changes
Contribution
Profiling code
Profiling before this change
retained memory by location
retained memory by class
Profiling after this change
retained memory by location
retained memory by class