1. Win32Lib: running out of memory with createDIB()
- Posted by Ben Logan <wbljr79 at HOTMAIL.COM>
Apr 09, 2000
-
Last edited Apr 10, 2000
Greetings,
If I create a DIB like this (using Win32Lib)
dib = createDIB(myBitmap)
and then later create another DIB using the same variable:
dib = createDIB(myOtherBitmap),
does the memory taken by the first DIB get released? The program I'm
writing has a voracious appetite for memory and, best I can tell, it's
because I keep creating DIB's (as many as a thousand) without releasing the
memory they use. I only need 56 (small) DIBs at once, but need to create
many more than that during the course of my program.
At first I thought that, since I was using the same variable each time it
would re-use the same memory. But then I realised that the variable is an
integer which apparently just points to the DIB. So
each time I re-use the variable, I lose the handle to that DIB--leaving a
chunk of memory that can't be accessed. Am I right?
Is there any way that I can release the memory that a DIB is using before I
destroy the handle to it?
Thanks,
Ben
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
2. Re: Win32Lib: running out of memory with createDIB()
- Posted by Brian Broker <bkb at CNW.COM>
Apr 09, 2000
-
Last edited Apr 10, 2000
On Sun, 9 Apr 2000 20:45:32 EDT, Ben Logan <wbljr79 at HOTMAIL.COM> wrote:
>At first I thought that, since I was using the same variable each time it
>would re-use the same memory. But then I realised that the variable is an
>integer which apparently just points to the DIB. So
>each time I re-use the variable, I lose the handle to that DIB--leaving a
>chunk of memory that can't be accessed. Am I right?
You are correct.
>Is there any way that I can release the memory that a DIB is using before I
>destroy the handle to it?
Yes, there is an undocumented procedure in Win32Lib called 'deleteObject'
that will take that handle and free it's resources before you re-use it.
global procedure deleteObject( atom handle )
-- deletes an object if not a stock resource
-- removes it from the tracking list
-- Brian
3. Re: Win32Lib: running out of memory with createDIB()
- Posted by wolfgang fritz <wolfritz at KING.IGS.NET>
Apr 09, 2000
-
Last edited Apr 10, 2000
If you are sure you're done with a bitmap for a while, you should release the
memory with:
deleteObject().....
example:
dib=createDIB(myBitmap)
dib2=createDIB(myOtherBitmap
-- then, when you're done with these...
deleteObject(dib)
deleteObject(dib2)
> If I create a DIB like this (using Win32Lib)
> dib = createDIB(myBitmap)
> and then later create another DIB using the same variable:
> dib = createDIB(myOtherBitmap),
> does the memory taken by the first DIB get released? *NO*
Wolf