-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JsonNode.ToJsonString(JsonSerializerOptions options) Throw OutOfMemoryException #67943
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsDescriptionOccasionally throw memory overflow when using JsonNode.ToJsonString Reproduction StepsThe size of a single JsonObject is within 30000000 bytes var transObj = new JsonObject(); Expected behaviorReturn string Actual behaviorThrow OutOfMemoryException dumps: https://github.com/saber-wang/dumps Regression?No response Known WorkaroundsNo response ConfigurationRun in container Other informationNo response
|
hi @saber-wang, could you also please provide what memory configuration you are using for the container? If you possibly have a sample json input that might help too. thanks |
Please if you can share minimal, runnable code that repros this. |
Sample JSON I try to print it out the next time the memory overflows |
Hi @saber-wang, did you mean to close this issue? If so was it resolved on your end? |
@mangod9 I got the JSON and tested it and found that the memory overflow is in line with expectations. However, the memory used by jsonnode is more than twice that of the original JSON. In the future, I may not use jsonnode but directly process strings I can provide a simple repros if necessary |
@mangod9 A simple example https://github.com/saber-wang/JsonObjetcTest |
Description
Occasionally throw memory overflow when using JsonNode.ToJsonString
Reproduction Steps
The size of a single JsonObject is within 30000000 bytes
var transObj = new JsonObject();
transObj .ToJsonString(new JsonSerializerOptions(JsonSerializerDefaults.Web)
{
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping
}))
Expected behavior
Return string
Actual behavior
Throw OutOfMemoryException
simple repros: https://github.com/saber-wang/JsonObjetcTest
Regression?
No response
Known Workarounds
No response
Configuration
Run in container
base image: mcr.microsoft.com/dotnet/runtime:6.0-alpine
memory configuration
Other information
No response
The text was updated successfully, but these errors were encountered: