C
C#17mo ago
marsastro

❔ WPF not disposing of memory on window close

I'm developing a WPF app that mostly lives in the taskbar corner, but that can open a window to change settings. When it's idling, it's using 38MB of memory. When I open the window for the first time, it shoots up to about 100MB of memory. The issue is that when I close the window, most of this memory remains in use. I've run some diagnostics and identified that the culprit is that during InitializeComponent the window loads a bunch of FontAwesome5 stuff (from external NuGet assemblies) into memory, and upon executing the Show command it adds hundreds of WeakReferences of the BindingExpression, ArrayList, ResourceDictionary, DependentList and AssemblyNameSpacePair types. It's not a problem that these are loaded into memory, as 100MB still isn't a lot, but it seems like such a waste to keep them around after closing the window given that the app will most likely run for hours and rarely if ever need to open the window again. Anyone have any idea why these resources aren't disposed of when Close is called, and how I can do something about that?
1 Reply
Accord
Accord17mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.