Hi,
I'm using Infragistics4 v12.1 with my winform application and decided to build dynamically the TreeNodeCollection attached to my UltraTree.This TreeNodeCollection contains one root node and multiple child nodes on potentially a lot of levels (depth).
I figured it would be more efficient to create this TreeNodeCollection instead of binding a collection.In the class that builds the TreeNodes hierarchy, I also set some Appearances on the cells based on their values.
I thought it would be a good idea to keep these Appearance instances as static references of that building class since they would be used multiple times (thousands).
By doing so, I realized that the TreeViewNodes are not Garbage Collected, even if they were disposed manually. So I'm back to cloning as many instances of the Appearance instances as the number of cells that should display a green background for example.
Is there a better way to do it ? Is this memory leak normal ?
I ran your sample through the Ants Memory Profiler and I don't see any memory leaks here.
I made one small change to your sample - I added some code to force a garbage collect after clearing the nodes.
What I did was I ran your sample and clicked the UltraTree button to show the tree form. Then I added nodes to the tree and clicked ExpandAll. At this point, I took a memory snapshot.
Then I cleared the nodes and took another snapshot and compared the two and there were a few minor increases in the number of instances of certain DotNet Framework classes. But nothing significant or related to the tree nodes or the appearances.
So what makes you think there's a memory leak here? What classes are not properly being disposed or GC'd?
Hi Mike,
Thanks for your answer. I've attached here the project I'm using to investigate this particular case.
You will see in the TreeNodeBuilder class the two ways to associate Appearance (the leaky one and the non-leaky one).
Thanks,
If you dispose the node and it's still not getting garbage collected, then that's a bug. Can you post a small sample project demonstrating this behavior?