作者:u02022042 | 来源:互联网 | 2023-05-17 12:30
Thereisawinformsapplication,wherecoupleofformsareverycomplicated-usingdatasets,multip
There is a winforms application, where couple of forms are very complicated - using datasets, multiple bindings with grids and comboboxes.. Every time when I open the form, the memory usage grows for about 2-5 MB until I get OutOfMemoryException. I use using
statements for every IDisposable
(for Form
s too), tried to clear all the bindings and unsubscribe my events within Dispose(), nothing changed. If I call GC.Collect()
after disposing the form, used memory amount returns in previous state, as it was before opening the form. I have tried some memory profilers, but they did not show anything extraordinary.
有一个winforms应用程序,其中几个表单非常复杂 - 使用数据集,多个绑定与网格和组合框。每次打开表单时,内存使用量增长约2-5 MB,直到我得到OutOfMemoryException。我对每个IDisposable使用using语句(对于Forms也是如此),尝试清除所有绑定并取消订阅Dispose()中的事件,没有任何改变。如果我在处理表单后调用GC.Collect(),则使用的内存量将返回之前的状态,就像打开表单之前一样。我已经尝试了一些内存分析器,但它们没有显示出任何特别的东西。
3 个解决方案