-
Notifications
You must be signed in to change notification settings - Fork 321
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
XmlLayoutSerialer memory leak #356
Comments
Well, we are no longer on that project with @RadvileSaveraiteFemtika. But @pkindruk tells true. @Dirkster99 he suggested three approaches. I could make changes for the second one (caching) or you can simply do the first one: revert the changes. Waiting for you answer. |
I am finding that having a debugger attached while serializing layout causes it to take several seconds to complete. Is that related to the heavy reflection and leaking? I didn't notice the memory leak myself but it would be affecting me because I do auto layout saving very often. Maybe there is an earlier package version you could suggest without the performance issue? |
It is all written if first post @romen-h Affected versions: 4.60.1 and above. Use anything below < 4.60.1. |
@audryste If you could prepare a PR to implement the recommended implementation that comes without memory leaks, I'd be more than happy to apply it :-) |
Pull request #308 introduced memory leak each time you serialize/deserialize layout. Affected versions: 4.60.1 and above.
This behavior is persistent across multiple runtimes net48, netcoreapp3.1, net 5.0, net 6.0.
Our projects has auto-save layout feature so memory grows pretty quickly.
Plain C# repro:
Final console app memory consumption is around 500MiB depending on runtime. However
GC.GetTotalMemory()
shows that it is not a object allocation issue. Console output:Debug output with
XmlSerializer.FromTypes(Type[])
contains:While debug output with
XmlSerializer.ctor(Type)
contains:Looks like
XmlSerializer.FromTypes(Type[])
generates dynamic assembly or type with serialization logic every time we call it in runtime. Which stays there until app restart and causes memory leak.I see a few solution to this issue:
XmlSerializer.ctor(Type)
. However this will get us back toSystem.IO.FileNotFoundException
which is still better than memory leak.XmlSerializer.FromTypes(Type[])
result. However this requires changing serialization logic..nuspec
.The text was updated successfully, but these errors were encountered: