-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Replace ReusableTextReader with shared ArrayPool #43365
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
Replace ReusableTextReader with shared ArrayPool #43365
Conversation
|
cc @jkotas, @danmosemsft |
src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.TryReadStatusFile.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.TryReadStatusFile.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.TryReadStatusFile.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.TryReadStatusFile.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.TryReadStatusFile.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.TryReadStatusFile.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.TryReadStatusFile.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.TryReadStatusFile.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.TryReadStatusFile.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.TryReadStatusFile.cs
Outdated
Show resolved
Hide resolved
| } | ||
| finally | ||
| { | ||
| ArrayPool<byte>.Shared.Return(bytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jkotas I have seen in some cases we don't bother to return in exceptional cases. Yet, I could imagine for some OS reason, we are always failing to read this file, and we are called often, so we drain the array pool. I guess it depends on the context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it depends on the context. I think the try/finally is appropriate here.
|
failure is #43200 |
|
thanks @am11 |
ReusableTextReaderis only used internally on Linux and it allocates buffers in the ctor. Instantiating it in a static context makes the CoreLib linker unfriendly. This change replaces the usage of RTR withArrayPool<T>, and deletes the class.Fixes #43337