This is happening with the NuGet package ObjectListView.Official 2.9.1, with .NET Framework 4.7.2.
I can't figure out how to dispose of the objects that are loaded inside a TreeListView, even after disposing the TreeListView itself, with no references present elsewhere. The objects are not even on the GC finalizer queue.
Below is a simple reproducible example I've been doing tests with.
public FormTreeList()
{
InitializeComponent();
List<Node> nodes = new List<Node>();
for (int i = 0; i < 500; i++)
{
nodes.Add(new Node("Node" + i.ToString()));
}
olvColumnValue.AspectGetter = delegate (object x) { return ((Node)x).Value; };
this.treeListView1.SetObjects(nodes);
}
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
//Disposing of the references
treeListView1.ClearCachedInfo();
treeListView1.CanExpandGetter = null;
treeListView1.ChildrenGetter = null;
treeListView1.ParentGetter = null;
treeListView1.Columns.Clear();
olvColumnValue.AspectGetter = null;
olvColumnValue = null;
treeListView1.Roots = null;
treeListView1 = null;
components.Dispose();
}
base.Dispose(disposing);
}
public class Node
{
public string Value { get; set; }
public Node(string value)
{
Value = value;
}
}
This is a graph from RedGate ANTS tool showing what is still holding a reference to one of the Node, after the FormTreeList was disposed.
I can figure out that the cachedLayoutEvent is keeping my references alive, but how can I unsubscribe from it since it is private?
Is this a bug from ObjectListView?
