I have a large, complex Windows Forms app written in VB.Net. Users are experiencing some memory issues and using JetBrains dotTrace Profiler to try and clear a few of these up.
There is still something holding some of my objects open. I have a 'Customer' object, which has a Generic.List
of InvoiceLineItem
. This item is basically an object bound to a grid control (ConponentOne FlexGrid) which has a load of readonly properties for displaying data, for example:
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
etc.
This object looks like it is not getting released from the FlexGrid.
The Flexgrid is on child form, shown from the main form. When the child form is closed, the Memory Profiler is showing that the form is still referenced.When I click "shortest Path" in dotTrace, the path below is shown.
This appears to be the only object in Customer with a root path.
There is no custom event handling going on in this form between my object or collection, and nothing is disposed.
What should I do to troubleshoot this further?
I found the issue. The FormClosing event was being handled elsewhere and tested for unsaved data, the reference to the form was being held in that function and not released!