Skip to content
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

MutableJsonChange can drain ArrayPool with undisposed JsonDocuments #38215

Closed
eerhardt opened this issue Aug 15, 2023 · 0 comments · Fixed by #38266
Closed

MutableJsonChange can drain ArrayPool with undisposed JsonDocuments #38215

eerhardt opened this issue Aug 15, 2023 · 0 comments · Fixed by #38266
Assignees
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library.
Milestone

Comments

@eerhardt
Copy link
Member

See the following code:

_serializedValue = JsonDocument.Parse(bytes).RootElement;

The JsonDocument returned from JsonDocument.Parse is backed by one or more ArrayPool arrays; those arrays are returned when the instance is disposed. If it's never disposed, the arrays are never returned to the pool. That means that creating but not disposing lots of JsonDocument instances ends up incurring the cost (and contention) of searching the ArrayPool but ends up falling back to allocating anyway.

This is a similar issue to AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet#2178.

We need to be disposing these JsonDocument objects. See these docs.

cc @annelo-msft

@github-actions github-actions bot added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 15, 2023
@jsquire jsquire added Client This issue points to a problem in the data-plane of the library. Azure.Core and removed needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Aug 16, 2023
annelo-msft added a commit to annelo-msft/azure-sdk-for-net that referenced this issue Aug 16, 2023
@annelo-msft annelo-msft self-assigned this Aug 17, 2023
@annelo-msft annelo-msft added this to the 2023-09 milestone Aug 17, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants