Skip to content

Comments

Fixed a potential memory leak risk in MemoryStreamExtension.Write#562

Open
Vincent-X-Zhang wants to merge 1 commit intoS7NetPlus:mainfrom
Vincent-X-Zhang:main
Open

Fixed a potential memory leak risk in MemoryStreamExtension.Write#562
Vincent-X-Zhang wants to merge 1 commit intoS7NetPlus:mainfrom
Vincent-X-Zhang:main

Conversation

@Vincent-X-Zhang
Copy link

Move the function ArrayPool<byte>.Shared.Return to the finally block.

@ynioba
Copy link

ynioba commented Feb 11, 2026 via email

}
finally
{
ArrayPool<byte>.Shared.Return(buffer);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The try-finally is actually not what one wants here. See dotnet/runtime#48257 (reply in thread) and the following comments.

Thanks for trying to address a problem anyway!
But I'd recommend to close this PR due the reasons mentioned in the link above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants