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

Avoid String allocations when writing strings that require special character handling #1191

Closed
ysanghi opened this Issue Jun 13, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@ysanghi
Contributor

ysanghi commented Jun 13, 2018

JsonValueUtils.WriteEscapedJsonString allocates additional strings when dealing with special characters.

Assemblies affected

OData .NET LIB

Additional detail

JsonValueUtils WriteEscapedJsonString uses Substrings to write strings to underlying textwriter but because of the immutable nature of .NET strings it allocates new strings. To further this, strings are objects in .NET and this makes objects visible to GC. This lead high allocations and excessive work needed by GC to clean this objects up. This can be avoided by using a buffer.

@AlanWong-MS

This comment has been minimized.

Contributor

AlanWong-MS commented Jun 21, 2018

Thanks for filing the issue and opening a PR! The fix has now been merged and should be included in our upcoming ODL release. ETA for the release is slated for end of the month.

@AlanWong-MS AlanWong-MS added this to the OData Lib 7.5 milestone Jun 21, 2018

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