问题描述
使用的WinForms
你有空闲的内存使用GDI对象,事件处理程序,从原生代码等对象后。
Working with WinForms
you have to free memory after using gdi objects, event handlers, objects from native code, etc.
在的WinForms
我用来除去在dispose方法示例事件处理程序。
In WinForms
I used to remove for example event handlers in the dispose method.
什么是以防止内存泄漏在 WPF
最好的解决方法?是不是等同于的WinForms
使用 Dispose模式
?在所有的,我需要关心的事件处理程序,在 WPF
GDI对象?有关运行时创建的资源是什么(刷子
等)?
What is the best workaround to prevent memory leaks in Wpf
? Is it the same as in Winforms
using Dispose pattern
? At all, do I have to care about event handlers, gdi objects in Wpf
? What about the runtime created resources(Brushes
, etc)?
推荐答案
的博客文章列出了导致WPF内存泄漏最常见的情况应用程序。
This blog post lists the most common situations that cause memory leaks in WPF applications.
- 事件处理程序的父窗口对象
- 注册从静态对象的事件
- 使用定时器
- 数据绑定
- 更改文本框的Text属性
- Event handlers to objects in parent windows
- Registering to events from static objects
- Using timers
- Data binding
- Changing the Text property of a text box
还介绍了如何解决这些常见问题。
It also describes how to fix these common issues.
另一个好方法是开发一个应用程序,而按照标准的指导方针,然后使用某种类型的探查,以确定任何内存泄漏或性能瓶颈。
Another good approach is to develop an app while following the standard guidelines and then use some kind of profiler to determine any memory leaks or performance bottlenecks.
这篇关于防止在WPF内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!