I have a tree that I am generating that can possibly generate 1000's of nodes. Each node has an icon and text.
In situation where I have a couple of hundred, no problem. When I get into the 1000's, I get 'Out Of Memory' errors. If I take out the icons, no issue.
Not sure where to start with this, but I have an imagelist with 16x16 icons...png's. (Very small)
Here is an example of how I am generating certain levels of the tree:
UltraTreeNode worknode = null;
public void GenerateDash(UltraTree tv)
{
worknode = tv.GetNodeByKey(SQLReader.GetString(21) + SQLReader.GetInt32(24));if (worknode == null){if (sid) worknode = tv.Nodes[SQLReader.GetInt32(24) + "mc"].Nodes.Add(SQLReader.GetString(21) + SQLReader.GetInt32(24), SQLReader.GetString(21)); else worknode = tv.Nodes["me"].Nodes[SQLReader.GetInt32(24) + "emp"].Nodes[SQLReader.GetInt32(24) + "mc"].Nodes.Add(SQLReader.GetString(21) + SQLReader.GetInt32(24), SQLReader.GetString(21));worknode.LeftImages.Add(tv.ImageList.Images[12]); }if (tv.GetNodeByKey(SQLReader.GetString(21) + SQLReader.GetInt32(24) + SQLReader.GetString(22)) == null) { worknode = worknode.Nodes.Add(SQLReader.GetString(21) + SQLReader.GetInt32(24) + SQLReader.GetString(22), SQLReader.GetString(22)); worknode.LeftImages.Add(tv.ImageList.Images[35]);}else worknode = tv.GetNodeByKey(SQLReader.GetString(21) + SQLReader.GetInt32(24) + SQLReader.GetString(22));
}
Before this I had a standard .net tree which generated the same amount of nodes with the icon with no issue.
Thanks.
I stepped the imagelist itself from 32 to 16 bit color depth. That and I changed out all of the png's to ico's. This resolved the out of memory issue. The silly thing is that after I changed all of the images to ico's, the ico's are twice the size of the png's. I just assumed they would be smaller. (2K instead of 1K).
I have to tell you, that while I did have an image list associated to the tree, I changed worknode.LeftImages.Add(tv.ImageList.Images[12]) to your suggestion and it cut the time it takes the tree to generate in half. I have read your post regarding memory considerations for the ultragrid, is there one for the tree? We use a lot of the trees.
There are 34 images in the list, though only half are being used with any real frequency. My test data is returning over 20K nodes in total.
Hi,
What version of the tree are you using?
You might want to try specifying an index to the LeftImages collection instead of an image.
For example, you could do this:
worknode.LeftImages.Add(12);
This will work the same as what you have now, assuming that you have set the tree's ImageList property to your tv.ImageList. This also assumes that you are only using one ImageList for all of your images.
If that does not help, then we would need to look into this further. How many different images do you have? I assume you don't have thousands of images, but you are probably re-using the same set of images for multiple nodes.
If you could provide a small sample project demonstrating the issue, we would be happy to take a look.