-
Notifications
You must be signed in to change notification settings - Fork 5k
Stream copy default buffer size causes allocation to go to LOH. #43179
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
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Thanks, yeah, this was discussed here: |
I see, thanks for linking it. I'm not sure if it's worth updating the constant to 128kB to reflect the actual size it gets from the |
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process. This process is part of our issue cleanup automation. |
This issue will now be closed since it had been marked |
The constant was picked up to prevent allocation in LOH:
runtime/src/libraries/System.Private.CoreLib/src/System/IO/Stream.cs
Lines 30 to 33 in f7d251f
Then we refactored
Stream.CopyTo*
to useArrayPool
(commit from Oct 2016) which rents buffers in nearest, big enough, 2^n size:runtime/src/libraries/System.Private.CoreLib/src/System/Buffers/Utilities.cs
Lines 17 to 22 in 50ac454
This will lead to renting a buffer with the size of
131 072
, falling over the LOH threshold.I believe this side-effect was unintentional. The question is whether it's worth fixing since the buffer gets reused?
Discovered while investigating: dotnet/yarp#151
cc: @stephentoub
The text was updated successfully, but these errors were encountered: