Dirkster99 / AvalonDock

Our own development branch of the well known WPF document docking library
Microsoft Public License
1.41k stars 321 forks source link

Add XmlSerializer cache to fix memory leaks. #403

Closed pkindruk closed 1 year ago

pkindruk commented 1 year ago

Implemented 2nd option I suggested in #356

eriove commented 1 year ago

Not a maintainer, just an user. Would it be safer to use a ConcurrentDictionary? Before this change the write-operation was thread safe. Even though I can not really thing of a reason to save it multiple times it is an easy change to make to avoid running in to tricky bugs.

pkindruk commented 1 year ago

@eriove good point on thread safety, thanks.

Normally you do serialize/deserialize on UI thread since XmlLayoutSerializer uses DockingManager.Layout dependency property. However all those implementation of IXmlSerializable are public and can be invoked in custom ways, so thread safety might be needed.