在WPF C#内存泄漏 [英] Memory leaks in wpf C#

查看:263
本文介绍了在WPF C#内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个WPF MVVM(在v3.5版本)的应用程序使用GalaSoft.MvvmLight套件和WPF工具包的DataGrid 的DatePicker 。但是我每一次我在主窗口加载用户控件面临着大量的内存泄漏的应用程序。我想获得通过赛特内存分析器确切的问题,但我有一些严肃的问题:

I am developing a WPF MVVM (in v3.5) application using GalaSoft.MvvmLight suite and WPF Toolkit for DataGrid and DatePicker. However I am facing lots of memory leaks in the application every time I load a UserControl in MainWindow. I am trying to get the exact issue via Scitech Memory profiler, though I have some serious questions :

  1. 如何解开/解除绑定的 RelayCommand 事件在虚拟机?
  2. mscorlib程序和presentationFramework也消耗大量内存,其中大部分是字符串。我不知道他们是从哪里来的。
  1. How to unhook/unbind the RelayCommand from the Event in VM?
  2. mscorlib and PresentationFramework are also consuming lots of memory and most of them are strings. I don't know where they are coming from.

请帮忙。

推荐答案

看一看这些文章就知道了内存泄漏的原因在WPF中,有解决方案,以及如何找到它们 -

Have a look at these articles to know causes of memory leaks in WPF, there solutions and how to find them -

查找内存泄漏在基于WPF的   应用:

Finding Memory Leaks in WPF-based applications:

<一个href="http://blogs.msdn.com/b/jgoldb/archive/2008/02/04/finding-memory-leaks-in-wpf-based-applications.aspx" rel="nofollow">http://blogs.msdn.com/b/jgoldb/archive/2008/02/04/finding-memory-leaks-in-wpf-based-applications.aspx

在WPF应用程序的内存泄漏:

Memory Leaks in WPF applications:

http://svetoslavsavov.blogspot.com/2010/05/memory-leaks-in-wpf-applications.html

查找托管内存泄漏   和Silverlight应用程序:

Finding Managed Memory Leaks in WPF and Silverlight applications:

<一个href="http://blogs.msdn.com/b/wpftesting/archive/2009/03/21/finding-managed-memory-leaks-in-wpf-and-silverlight-applications.aspx" rel="nofollow">http://blogs.msdn.com/b/wpftesting/archive/2009/03/21/finding-managed-memory-leaks-in-wpf-and-silverlight-applications.aspx

如果你正在使用WPF 3.5 SP1,看看这些补丁程序 -

In case you are using WPF 3.5 SP1, have a look at these hot-fixes -

内存泄漏的修补程序的WPF 3.5 SP1

Memory Leak Hotfixes for WPF 3.5 SP1

http://blogs.msdn.com/b/jgoldb/archive/2010/06/14/memory-leak-hotfixes-for-wpf-3-5-sp1.aspx

导致内存泄漏的一些较为少见的情景 -

Some more rare scenarios causing memory leaks -

http://blog.ramondeklein.nl/?p=58

http://$c$c.logos.com/blog/2008/10/detecting_bindings_that_should_be_onetime.html

这篇关于在WPF C#内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆