WinForms控制内存问题? [英] WinForms controls memory issue?
问题描述
我正在经历一个奇怪的内存泄漏".当我使用按钮启动程序时. 以下为摘要:
I am experiencing a strange "memory leak" when I am using a pushbutton to start my program. Here is a snippet:
使用Kitware.VTK
using Kitware.VTK
我的代码的主体"
"Body of my code"
}
}
}
}
}
我的问题是我的代码正文"中的内存直到我超出button_test_Click的范围,再也不会清除. 我的代码正文"中存在一个循环应该可以重新处理约5MB的图像数据,但是看起来 内存只会将每次迭代加起来.
My problem is that the memory in "Body of my code" never clears until I get out of the scope of button_test_Click. There is a loop in "Body of my code" that is supposed to re-process ~5MB of image data, but instead it seems as though the memory just adds-up each iteration.
我知道这是按钮的问题,因为当我放置我的代码正文"时,在相同范围内,在InitializeComponent()之后,内存不会增长. 似乎在button_test_Click内部垃圾回收不起作用 方法.
I know this is a problem of the pushbutton, because when I place "Body of my code" right after InitializeComponent(), within the same scope, memory does not grow. It seems as though garbage collection does not work inside of the button_test_Click method.
有什么建议吗?
推荐答案
您是否正确处置了用于处理图像的对象,即调用Dispose()或使用;使用?
Are you properly disposing of the objects that you are using to process the image, i.e. calling Dispose() or by using "using"?
这篇关于WinForms控制内存问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!