我有一个用VB.Net编写的大型复杂Windows窗体应用程序。用户遇到了一些内存问题,并使用JetBrains dotTrace Profiler尝试清除其中的一些内容。
还有一些东西让我的一些物体打开。我有一个“客户”对象,其Generic.List
为InvoiceLineItem
。此项基本上是绑定到网格控件(ConponentOne FlexGrid)的对象,该控件具有用于显示数据的只读属性,例如:
Public Class InvoiceLineItem
Private _customer as Customer
Private _charge as Charge
Sub New(Customer as Customer, Charge as Charge)
_customer = Customer
_charge = Charge
End Sub
Public ReadOnly Property Name as String
Return _customer.Name
End Property
Public ReadOnly Property ItemName as String
Return _charge.Name
End Property
Public ReadOnly Property Amount as Decimal
Return _charge.Amount
End Property
End Class
等
此对象看起来没有从FlexGrid中释放。
Flexgrid是子表单,从主表单中显示。当子窗体关闭时,Memory Profiler显示表单仍然被引用。当我点击dotTrace中的“最短路径”时,将显示以下路径。
这似乎是Customer中唯一具有根路径的对象。
我的对象或集合之间没有在此表单中进行自定义事件处理,也没有任何处理。
我应该怎么做才能进一步解决这个问题?
答案 0 :(得分:0)
我发现了这个问题。 FormClosing事件正在其他地方处理并测试未保存的数据,对该表单的引用是在该函数中保存而未发布!