HashTable problem

EFileTahi-A

Contributor
Joined
Aug 8, 2004
Messages
623
Location
Portugal / Barreiro
How the Foxtrot can I release the Hashtable's associated resources?

I load 30 large bmps which will "eat" about 45MB of ram. Then, If I reload them, an aditional 45MB will be consumed. So, basicaly, If I reload these pictures 5 times more the 200MB will be consumed, even with the myHasTable.Clear() property and the CollectGarbage before reloading these images...

Also, the Hashtable don't have the "Dispose()" property... What the...

This Hastable of mine is static so I would only like to dispose it's associated resources rather then disposing the object itself...
 
something like
C#:
System.Collections.Hashtable h = new Hashtable();

//add stuff in
h.Add("test", new Bitmap(1000,1000));

//to dispose
foreach (object o in h.Values)
	{
	IDisposable d = o as IDisposable;
	if (d != null)
		d.Dispose();
	}
should do it
 
isnt this what an image list is for? Wont disposing an image list dispose the Bitmaps?

load your images into an image list.
Add references to the images to a hash table.
to free, dispose the image list, reset your hashtable.
 
I believe what Joe Mamma meant was that you can add an image of any size to an image list, but it automatically resizes the Image to the size specified by the Image list (which is a maximum of 256).
 
Cags said:
I believe what Joe Mamma meant was that you can add an image of any size to an image list, but it automatically resizes the Image to the size specified by the Image list (which is a maximum of 256).

Yeah I understood that. What I did not realise was if that "resize thingie" also happens in v2.0 :)
 
Back
Top