TabControl.Items.Remove(TabItem的)不使用TabItem的空闲内存 [英] TabControl.Items.Remove(TabItem) does not free memory used by TabItem
问题描述
我有一个WPF应用程序时,我关闭,其中一个的TabItem
从的TabControl
使用 TabControl.Items.Remove(TabItem的)
不使用释放内存的的的TabItem 的。它只是使的的的TabItem 的无形和的的TabItem 的对象仍然保留在内存中。有没有什么办法可以从内存中删除此的的的TabItem 的的对象?任何帮助将是AP preciated。
I am having a WPF application where when I close a TabItem
from TabControl
using TabControl.Items.Remove(TabItem)
does not free memory used by TabItem. It just makes TabItem invisible and TabItem object still remains in the memory. Is there any way to remove this TabItem object from memory ? Any help would be appreciated.
推荐答案
据我所知,所有的事件处理器必须'独立',你也应该释放所有绑定在你的TabItem。
As far as I know all eventhandlers must be 'detached', also you should release all bindings on your tabItem.
另外,如果我没有记错CommandBindings,KeyGestures也会造成泄漏。
Also If I am not mistaken CommandBindings, KeyGestures can also cause the leak.
尝试使用CLR探查。它救了我很多时间很多次了,虽然我还没有与WPF使用过它。但我pretty的确保它可以处理它。
Try using CLR Profiler. It has saved me a lot of hours many times, though I haven't used it with WPF. But I'm pretty sure it can handle it.
这篇关于TabControl.Items.Remove(TabItem的)不使用TabItem的空闲内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!