Resource Manager vs Resource File C#
Posted on 2011-03-19
I have a resource setup with a bunch of 16x16 PNG's that we use for images on a tree view.
We build this treeviews in code and we used to use an imagelist which gaves us trouble so we were adding the images like this:
Now, on a large set of data (7K records, 3 nodes deep so that is 21K nodes) we would randomly get out of memory errors. Even on a dev machine with 8gig ram. So, I did a little digging and found the resourcemanager class in System.Resources, and tried this;
ResourceManager rm = new ResourceManager(resourceFile, etc);
I decided before I go further, let me ask, which way is right? Or should I before the loop that populates the tree create an instance of the image? I want to enusre that ONE instance of the image exists, but also want to follow best practices.
Image phone = (Image)rm.GetObject etc;