MemoryLeak带转换器 [英] MemoryLeak with converter
问题描述
全部,
在自定义控制中使用转换器作为静态资源即使关闭窗口,也会发生内存泄漏。
附加样品,请在下面找到截图。
您能为此建议任何解决方案吗?
注意:我已经在ANTS个人资料中检查了这个。 示例
链接
While using converter as static resource in custom control Memory leak occurs even when the window is closed.
Sample attached and please find the screenshot below.
Can you please suggest any solution for this?
Note: I have checked this in ANTS profile.Sample
Link
推荐答案
您好PriyangaB,
Hi PriyangaB,
您可以尝试使用GC来处理window_closing事件中的资源。
You can try to use GC to dispose resource in window_closing event.
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
cus1 = null;
GC.Collect();
GC.WaitForPendingFinalizers();
}
也许没有问题。 GC非常惰性,任务管理器显示分配的内存与GC实际使用的内存不同。 GC可能将对象放在一次性列表中,但只是看不到它。
Perhaps there isn't a problem. The GC is very lazy and task manager shows the memory allocated which is different to what the GC is actually using. The GC may have the objects in a disposable list but just sees no point to it just yet.
最好的问候,
Cherry
这篇关于MemoryLeak带转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!