Setting current theme causing memory to go up by ~4MB

Ribbon for WPF Forum

Posted 14 years ago by Balaram Barange
Version: 10.1.0523
Avatar
Hi,

In our App constructor we have following line of code:
ActiproSoftware.Windows.Themes.ThemeManager.CurrentTheme = ActiproSoftware.Windows.Themes.CommonThemeName.Office2007Blue.ToString();

After executing above code line the task manager for the application shows an increase of ~4 MB. Could you please let us know what are we doing wrong here as setting other third party controls in the same manner do not show such behavior.

Thanks,
Bala

Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Bala,

As I believe we've mentioned before, using task manager for memory tracking is never a good thing because it doesn't accurately track .NET memory. We recommend using something like the profiler app at memprofiler.com, since apps like those will give you accurate memory results.

Memory will increase when you change themes from the default. When the controls are initially created, WPF is automatically loading the appropriate system theme for the controls, meaning all of its brushes, styles and templates. When you set the ThemeManager.CurrentTheme, we are loading up another full theme and are putting it in the Application.Resources. As you switch themes after that, we swap out the resources for the old theme and add the new appropriate ones.

Note that we do not have access to remove the "system" ones that are automatically put in place by WPF when the application is loaded. Therefore if you set ThemeManager.CurrentTheme to a theme, you effectively have two sets of themes loaded, one that is system-loaded and one that we put in the Application.Resources to override the system-loaded ones.

There isn't really any other way to achieve dynamic theming. Of course the more assemblies you are using, the more brushes/templates/styles will be loaded each time a theme is used.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.