voodoochile Posted December 9, 2003 Posted December 9, 2003 I have written a program in VB.Net that essentailly can create a mosaic picture. It opens the smaller tile pictures, does some processing, and then weaves the smaller tiles into the larger mosaic picture. The program works fine except that with large images (over about 2000x2000 pixels), I get an "Out of Memory Error". I am running the program on a Windows 2K, P4, with 512MB of RAM and the VM set at about 1.5GB. As I watch in the Performance section of the Task Manager, the program usually only takes about 20MB, but the VM obviously is out of control. I am using 2 graphics objects and 2 bitmap objects as I shuffle the images around in processing. In each pass through the loop building my mosaic, I am using a: graphics = nothing graphics.dispose() -- or a -- bitmap = nothing bitmap.dispose() So I think I am releasing my stored resources. What can be done to either be more efficient with clearing the memory or using the variables in a cleaner way? Quote
voodoochile Posted December 9, 2003 Author Posted December 9, 2003 I added some code to force garbage collection after every 20th tile: If i / 20 Mod 0 Then GC.Collect() End If Is this a bad practice? Quote
donnacha Posted December 15, 2003 Posted December 15, 2003 Hi voodoochile, try doing the bitmap.dispose before the bitmap = nothing etc.. and see if this helps. I would leave the GC.collect call as well. Quote Hamlet
Leaders snarfblam Posted December 15, 2003 Leaders Posted December 15, 2003 Don't you have to dispose it before you release the reference so that it has a reference to the resources that you are trying to dispose of? Quote [sIGPIC]e[/sIGPIC]
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.