In Visual Basic 2008, is there a command to free all unmanaged memory?
I have a program which generates bitmap data in unmanaged memory, then makes a Bitmap object using the constructor with parameters (width, height, stride, pixel format, scan0). However, I can't release the memory until the bitmap is no longer needed, which is at the point the program exits. There may be multiple bitmaps created in this way, and it would be difficult to keep track of all the unmanaged memory used along the way. Is there a command to free all unmanaged memory, or will .NET make this happen automatically when my program exits?
I've tried cloning the Bitmap using the Bitmap.Clone method, but that doesn't help - the bitmap is still corrupted when I release the unmanaged memory.
|