wieslawsoltes / Dock

A docking layout system.
https://wieslawsoltes.github.io/Dock/
MIT License
853 stars 94 forks source link

[Bug] [Memory Leak] Closed Documents are not collected by the GC #340

Open ArchLeaders opened 1 month ago

ArchLeaders commented 1 month ago

When closing documents in a DocumentDock, the GC never collects the removed view models.

I'm not very good with memory diagnostics, but from what I could understand, several Avalonia.PropertyStore.EffectiveValue<Object> instances hold the view model.

From what I can tell these property stores are part of the visual tree, which is not something I am familiar with.

I also observed that clearing the VisibleDockables from both the DocumentDock and ProportionalDock (parent of the DocumentDock) allows every open or closed document to be collected by the GC. Clearing either one alone does not work.

To recreate the issue:


You can find a minimal sample app replicating this on my GitHub: ArchLeaders/DockAvalonia-MemoryLeakIssue


Avalonia Version: 11.0.10 Dock.Avalonia Version: 11.0.0.7

BAndysc commented 1 month ago

Unfortunately it's Avalonia fault. Some of the leaks are fixed in the latest master, but some are still waiting for a fix

https://github.com/AvaloniaUI/Avalonia/issues/15465

https://github.com/AvaloniaUI/Avalonia/issues/15444

https://github.com/AvaloniaUI/Avalonia/issues/15443

https://github.com/AvaloniaUI/Avalonia/issues/15094

https://github.com/AvaloniaUI/Avalonia/discussions/15455