You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Create a new Avalonia project and add Dock.Avalonia and Dock.Model.Mvvm (latest)
Create a main window with a DockControl bound to an IRootDock (Layout)
Create a Dock.Model.Mvvm.Factory implementation that overrides CreateLayout to create a DocumentDock inside a ProportionalDock inside a RootDock and return the root dock.
Create a DemoViewModel that implements Dock.Model.Mvvm.Controls.Document and a destructor with logging or a breakpoint
Create a CleanupCommand that clears the FocusedDockable or the root dock and calls GC.Collect() and GC.WaitForPendingFinalizers()
Add two new instances of DemoViewModel to the DocumentDock, close one and call the cleanup command. Observe that the destructor is never called.
Close the second instance and observe that both DemoViewModel's are destructed (the entire dock area is also missing after closing the last document).
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:
Dock.Avalonia
andDock.Model.Mvvm
(latest)Dock.Model.Mvvm.Factory
implementation that overridesCreateLayout
to create a DocumentDock inside a ProportionalDock inside a RootDock and return the root dock.DemoViewModel
that implementsDock.Model.Mvvm.Controls.Document
and a destructor with logging or a breakpointCleanupCommand
that clears theFocusedDockable
or the root dock and callsGC.Collect()
andGC.WaitForPendingFinalizers()
DemoViewModel
to the DocumentDock, close one and call the cleanup command. Observe that the destructor is never called.DemoViewModel
's are destructed (the entire dock area is also missing after closing the last document).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
The text was updated successfully, but these errors were encountered: