Skip to content

What exactly happens if I fail to return memory rented from the shared MemoryPool/ArrayPool? #43564

Answered by Clockwork-Muse
castholm asked this question in Q&A
Discussion options

You must be logged in to vote

Since there are no longer any references to the memory instances in my application code, will the rented memory eventually be reclaimed by the garbage collector or is it permanently lost? I've scoured through most relevant documentation but I couldn't find a clear answer.

For the default array pool (and the simple array-based Memory pool), it (as near as I can tell) releases ownership of the array memory on Rent, so the GC should collect it.

For context, I am passing IMemoryOwner<byte> instances around TPL Dataflow pipelines and I'm trying to understand what would happen if I fault or cancel a dataflow block and it clears its internal queue without disposing the contained elements.

Yo…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by GrabYourPitchforks
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants