[futurebasic] Re: [FB] Re: Need to Kill picture before to quit ?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2001 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Wed, 30 May 2001 11:10:10 -0400
>>>In the manual it is stated that handle of picture created using
>>>Picture ON/OFF should be liberated when not used. I use such an
>>>handle in my program every time then I don't need to kill it. But
>>>should I kill it before to quit the program or is it automatic ?
>
>>
>>This is just my opinion, but you should in general dispose of the image
>>with Kill Picture after you have drawn it where you needed it.
>
>>One thing you definitely don't want to leave laying around undisposed is an
>>offscreen GWorld. They will gather memory over time and sink you, as the
>>memory used may or may not get released, particularly if left locked.
>
>
>The program below allocates a large locked GWorld but fails to dispose of it.
>Running the program repeatedly (in OS 9.1) shows that TempFreeMem does not
>decline. The GWorld memory is completely restored at program exit; there
>is no memory leak from omitting the DisposeGWorld call. This remains true
>even if you allocate the GWorld in temporary memory (by setting
>_doUseTempMem appropriately).
>
>Automatic release of handle and pointer blocks in the application heap
>happened, I think, way back in system 7.

>I do not know when the useful feature was introduced of automatically
>releasing  temporary memory too.

RP,

Though it is my experience that being a memory clearing house is a good
idea, I think I have a memory apple and oranges situation here. Surely
don't want to mislead anyone about a funtionality situation.

There are 2 things I may have confused here....running my GWorld app in FB
II, where things _can_ pile up like that unless the editor is quit...and in
FB 3, where they can pile up as the program runs,  perhaps not when it
quits, my misstatement.

In FB II, running multiple runs without disposing of the GWorlds was a
problem, because of the common heap situation. Then one would have to quit
the editor.

Anyway, I try to always dispose of my gworlds and Picture handles, I feel
it is good housekeeping. And for me, it keeps out of memory message from
showing up when doing a lot of image stuff in either environment.

We are talking 1 line of code normally...

If theGWorld then call dispose(theGWorld):theGWorld = 0

or

If PictH then KillPicture(PictH):PictH = 0

I set the handle var to 0, because I use it being non-zero as a way of
calling or not calling things down the road as a flag.


RC