delete streams from the streams map when closing #91
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.
This should fix the incorrect memory accounting that users have been reporting (for example filecoin-project/lotus#8632).
There are two actions (at least) that release memory:
These can happen concurrently, which is not a problem, as we're holding the
streamLock
. We're also only releasing memory with the resource manager when the stream is still in our streams map.The condition that made us release too much memory was the following: First, we'd close the session, which would release the memory of all streams. At the same time, the user reset one of the streams. This call would execute once the session is closed and all memory is released. However, since we didn't delete the stream from the map, we'd effectively release the memory allocated for that stream twice.