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

v13.0.3 Memory Leak due to Reference Loop on .NET 8 #2933

Open
dlitty opened this issue Feb 8, 2024 · 1 comment
Open

v13.0.3 Memory Leak due to Reference Loop on .NET 8 #2933

dlitty opened this issue Feb 8, 2024 · 1 comment

Comments

@dlitty
Copy link

dlitty commented Feb 8, 2024

Source/destination types

We have database entities for Entity Framework that are being serialized. This code worked fine with .NET 7, but now that we are upgrading to .NET 8, it is apparently no longer ignoring self-references, even though we still have this code:

message_data = JsonConvert.SerializeObject(data, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore}),

Expected behavior

The objects get serialized

Actual behavior

Memory continues to grow until the OS runs out

Steps to reproduce

See above
@elgonzo
Copy link

elgonzo commented Feb 8, 2024

Steps to reproduce
See above

No, these are not steps to reproduce. That's like saying the recipe for chocolate cookies is: Bake!

Arguably, providing a relatively compact code example that reproduces this issue might be difficult, since you are using EF.

Arguably, the issue might perhaps not even be within Newtonsoft.Json but in some other piece of code that is being called by Newtonsoft.Json. Like for example, custom equality comparers (either coded by you or auto-generated by EF or some other code generator) which might be called by Newtonsoft.Json to figure out equality of instances for detecting reference loops.

There are so far no other issues reported that match your brief description as far as i am aware, and i can't imagine how a mere migration to .NET 8 would cause this. I suppose other things got updated as well in your project, not just a mere change of the target framework to .NET 8. But now i am just starting to read tea leaves... Therefore, the only advice i -- as another user of this library -- can give is that you thoroughly troubleshoot and profile your code with the data that triggers the runaway memory allocation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants