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
Describe the bug AdonisWindow is not being removed from memory after the window is closed. The window, its content, and its DataContext (i.e., business logic) is therefore not getting garbage collected.
Click on 'Launch Simulation' (this opens a new AdonisWindow).
Close the new window, but keep main window open.
Force or wait for garbage collection.
BUG: The closed AdonisWindow, its Content (of type SimulationView) and the its Content.DataContext (of type SimulationVM) still exist in memory.
Expected behavior
After closing the window, the AdonisWindow, the SimulationView, and the SimulationVM should have been eligible for garbage collection. However, there is a memory leak keeping them alive. From the DotMemory screenshots below, it looks like the culprit is a DependencyObjectPropertyDescriptor for the ActualHeight property. This descriptor was added in AdonisWindow.HandleTitleBarActualHeightChanged.
The method uses DependencyPropertyDescriptor.AddValueChanged. I think it needs to either use a weak event, or remove the handler at some point.
Screenshots
These screenshots are from JetBrains DotMemory, from a snapshot taken after doing "To Reproduce" and then forcing garbage collection.
Here you can see that SimulationVM is still in memory, and that AdonisWindow is keeping it alive. The path contains an EventHandler and a DependencyObjectPropertyDescriptor.
Here is the stack trace for the creation of the EventHandler in the previous screenshot. It shows that the event handler was created from AdonisWindow.HandleTitleBarActualHeightChanged while the window was opening.
Finally, here are some properties of the aforementioned DependencyObjectPropertyDescriptor, confirming that it's related to "ActualHeight".
The text was updated successfully, but these errors were encountered:
Describe the bug
AdonisWindow
is not being removed from memory after the window is closed. The window, its content, and itsDataContext
(i.e., business logic) is therefore not getting garbage collected.To Reproduce
Steps to reproduce the behavior:
AdonisWindow
).AdonisWindow
, itsContent
(of typeSimulationView
) and the itsContent.DataContext
(of typeSimulationVM
) still exist in memory.Expected behavior
After closing the window, the
AdonisWindow
, theSimulationView
, and theSimulationVM
should have been eligible for garbage collection. However, there is a memory leak keeping them alive. From the DotMemory screenshots below, it looks like the culprit is aDependencyObjectPropertyDescriptor
for theActualHeight
property. This descriptor was added in AdonisWindow.HandleTitleBarActualHeightChanged.The method uses
DependencyPropertyDescriptor.AddValueChanged
. I think it needs to either use a weak event, or remove the handler at some point.Screenshots
These screenshots are from JetBrains DotMemory, from a snapshot taken after doing "To Reproduce" and then forcing garbage collection.
Here you can see that
SimulationVM
is still in memory, and thatAdonisWindow
is keeping it alive. The path contains anEventHandler
and aDependencyObjectPropertyDescriptor
.Here is the stack trace for the creation of the
EventHandler
in the previous screenshot. It shows that the event handler was created fromAdonisWindow.HandleTitleBarActualHeightChanged
while the window was opening.Finally, here are some properties of the aforementioned
DependencyObjectPropertyDescriptor
, confirming that it's related to "ActualHeight".The text was updated successfully, but these errors were encountered: