Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
When to free an image?
#6
Since image handles are variables, I tend to treat images like their handle variables, some are global and some are SUB/FUNCTION local. The local ones, created at each routine call, are always freed before leaving the subroutine so that they don't consume more and more memory via multiple future routine calls. Global image handles are generally used often during the program so I leave them in memory, unless I'm sure I'm done with them. This is of course an oversimplification, highly dependent on the nature of what's going on in the program, but that's my typical approach.

Often, when coming into a routine that throws up temporary images such a dialog/input boxes, the very first thing I'll do is:
backimg& = _COPYIMAGE(0)

Then I:
localimg& = _{NEW/LOAD}IMAGE(x, y, mode)

'do stuff with localimg&

and finally:
_FREEIMAGE localimg&

Then before I leave the routine:
_PUTIMAGE, backimg&
_FREEIMAGE backimg&

That assumes no alteration of the main screens display during the call.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Reply


Messages In This Thread
When to free an image? - by James D Jarvis - 04-13-2023, 02:54 PM
RE: When to free an image? - by TerryRitchie - 04-13-2023, 03:28 PM
RE: When to free an image? - by SMcNeill - 04-13-2023, 05:02 PM
RE: When to free an image? - by James D Jarvis - 04-13-2023, 05:45 PM
RE: When to free an image? - by mnrvovrfc - 04-13-2023, 06:26 PM
RE: When to free an image? - by OldMoses - 04-16-2023, 08:55 PM



Users browsing this thread: 7 Guest(s)