Skip to content

Conversation

@am11
Copy link
Member

@am11 am11 commented Oct 13, 2020

ReusableTextReader is 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 with ArrayPool<T>, and deletes the class.

Fixes #43337

@am11
Copy link
Member Author

am11 commented Oct 13, 2020

cc @jkotas, @danmosemsft

}
finally
{
ArrayPool<byte>.Shared.Return(bytes);
Copy link
Member

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?

Copy link
Member

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.

@danmoseley
Copy link
Member

failure is #43200

@danmoseley danmoseley merged commit 041826b into dotnet:master Oct 14, 2020
@danmoseley
Copy link
Member

thanks @am11

@dotnet dotnet deleted a comment from jkotas Oct 14, 2020
@am11 am11 deleted the feature/cleanup/purge-reusabletextreader branch October 14, 2020 10:54
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid unconditional eager initialization of ReusableTextReader in System.Environment

4 participants