EFileTahi-A Posted January 15, 2006 Posted January 15, 2006 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... Quote
Administrators PlausiblyDamp Posted January 15, 2006 Administrators Posted January 15, 2006 You will need to dispose of the bitmaps in the hashtable, not the hashtable itself. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
EFileTahi-A Posted January 15, 2006 Author Posted January 15, 2006 Ok, but how will I do that? I'm loading the images from file directly to the hash table: myHashTable.Add(sKeyImageName, Image.FromFile(sPath)); Quote
EFileTahi-A Posted January 15, 2006 Author Posted January 15, 2006 Ok, nevermind... I made it :) Thank you PlausiblyDamp for the tip. - THREAD CLOSED - Quote
Administrators PlausiblyDamp Posted January 15, 2006 Administrators Posted January 15, 2006 something like 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 Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
EFileTahi-A Posted January 15, 2006 Author Posted January 15, 2006 Hmmm... interesting. I used another method though. But yours sounds more professional and definately less resourse consuming then mine. Quote
Joe Mamma Posted January 16, 2006 Posted January 16, 2006 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. Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
EFileTahi-A Posted January 17, 2006 Author Posted January 17, 2006 Hi Joe, Unfortunately the Image List object is limited to 256 by 256 pixels. Quote
Joe Mamma Posted January 18, 2006 Posted January 18, 2006 Hi Joe, Unfortunately the Image List object is limited to 256 by 256 pixels. yeah. . . that could be a problem I guess :o Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Joe Mamma Posted January 18, 2006 Posted January 18, 2006 yeah. . . that could be a problem I guess :oby the way. . . are you in 1.1 or 2.0? Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Joe Mamma Posted January 18, 2006 Posted January 18, 2006 I can add a 1024x768 to an imagelist in 2.0. is this a limitation to 1.1? Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Joe Mamma Posted January 18, 2006 Posted January 18, 2006 I can add a 1024x768 to an imagelist in 2.0. is this a limitation to 1.1? I can do it in 1.1 too. Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Joe Mamma Posted January 18, 2006 Posted January 18, 2006 I can do it in 1.1 too. ahh. . . Im a moron. . yeah I can add it. . . but it comes back out as the size specified by the Imagelist. that sux. Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
EFileTahi-A Posted January 18, 2006 Author Posted January 18, 2006 LOL! Now you confused me! You mean they resized in both 1.1 and 2.0? I'm using 1.1 by the way. Quote
Cags Posted January 18, 2006 Posted January 18, 2006 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). Quote Anybody looking for a graduate programmer (Midlands, England)?
EFileTahi-A Posted January 18, 2006 Author Posted January 18, 2006 I believe what Joe Mamma meant was that you can add an image of any size to an image list' date=' but it automatically resizes the Image to the size specified by the Image list (which is a maximum of 256).[/quote'] Yeah I understood that. What I did not realise was if that "resize thingie" also happens in v2.0 :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.