WPF DynamicResource memory leak

After some troubleshooting on WPF memory leaks, I came across a memory leak that occurs when using DynamicResource on resource keys declared in Application.Resources. You can read about this problem being discussed on msdn forum and stackoverflow. To fix this problem, fortunately there’s a patch for .NET 3.5 and .NET 4.0 resolved this issue.

If you’re developing in Silverlight, no issue as there’s no DynamicResource. If you’re developing in WPF, I urge you to consider if there’s a need at all to use DynamicResource. If you’re not using SystemColors, SystemFonts or themes in your application, StaticResource should be considered because DynamicResource are re-evaluated at runtime whenever the resource is requested which is an overhead. If you’re not familiar about their usages, you can read more about them here.

Posted in WPF. Tags: . Leave a Comment »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: