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 ?
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?
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,
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?
When the Appearance is static and you successively click the "Add Nodes" / "Clear Nodes" buttons multiple times, you will notice that the memory is rising very quickly and leads to a OutOfMemoryException in the most extreme cases.
On the other hand, by commenting that line and uncommenting the one that does a Clone() on the static Appearance before setting it to the Cell, the same operation leads to a stable memory.
I'm not definitive on the conclusions, maybe I'm doing something wrong but this seems a bit odd, no ?
I'm not seeing any increase in memory usage in my testing. How many times do I need to add and remove the nodes before the OutOfMemory exception occurs?
What, exactly, are you looking at - how are you measuring the memory usage?
Please ignore my previous post. I just tried again and I think I am seeing the issue, now. I'm not sure why I wasn't seeing it before, but there are an increasing number of event handlers that are being instantiated. I'm going to ask Infragistics Developer Support to create a case for you and write this up for developer review.
Hello Loic,
I have created support case CAS-118447-Q2X0K3 so that you may monitor the progress of the new development issue (144894). I provided more details on this through the case which you can view from your My Support Activity page. I will also post the resolution here once development issue 144894 is resolved.
Let me know if you have any questions.