Memory Leak Related to WindowChrome?

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 10 years ago by Jay Hill
Version: 14.2.0610
Avatar

Is there any known memory leak issue related to using the custom WPF window chrome?

We have applied it to all of our windows and find that memory is not being released. Transient windows (dialogs) are opened and closed, all the usual window close events fire, but over the course of using our application for a couple of hours memory usage climbs and performance degrades. Simply removing the chrome seems to solve this issue.

We have declared 2 instances of WindowChrome as static resources and all views bind to these (one for windows with an icon and one for those that don't have an icon).

We are using the Metro Dark theme.

Memory profiling points to an event called RenderPropertyChanged.

Is there anything that sounds wrong with our setup or are there suggestions for working around this issue (short of removing the chrome)?

Comments (4)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jay,

We aren't aware of any leaks but I do wonder if the way you are doing things is potentially causing problems.  We don't recommend reusing instances of WindowChrome.  I would try switching it so that each Window has its own WindowChrome instance and see if that resolves the issue for you, since that's the intended use of that class.


Actipro Software Support

Posted 10 years ago by Jay Hill
Avatar

Okay, we'll try that.

It is worth noting that the Window Chrome topic in the Actipro Themes documentation says WindowChrome can be shared as a static resource:

You could also apply the chrome to windows in an app by defining the chrome in your Application.Resources with an x:Key. Then reference that chrome in each Window's XAML like:

<Window xmlns:themes="http://schemas.actiprosoftware.com/winfx/xaml/themes"
    ...
    themes:WindowChrome.Chrome="{Static YourWindowChromeKeyHere}">
    ...
</Window>

Posted 10 years ago by Jay Hill
Avatar

We found that not sharing the resource resolved the issue.

Rather than declaring a new WindowChrome for all windows, we just went to the resource and added x:Shared="False". It would be great if this tidbit could be added to the docs.

Thanks for your help!

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jay,

I wanted to follow up.  We did some more looking into this and you can reuse an instance of WindowChrome across the various Windows but if you do that, be sure to clear the chrome reference as the window is closing for the last time and before the reference to it is lost.  For instance, you could do this in your Window's OnClosed override:

WindowChrome.SetChrome(this, null);


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.