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

Possibly Related Threads…
Thread Author Replies Views Last Post
  graceful way to test for a valid image handle such as before doing _FreeImage? madscijr 7 1,018 11-11-2025, 03:50 PM
Last Post: madscijr
  A strange experience with forum posting an image TempodiBasic 2 523 06-17-2025, 06:01 AM
Last Post: TempodiBasic
  QB64PE programming challenge? auto-convert image to photoreal etch-a-sketch drawing madscijr 9 1,826 02-14-2025, 05:49 PM
Last Post: madscijr
Rainbow Kenney Game Assets All-in-1 Free Day - on itch.io - not spam grymmjack 17 4,607 09-21-2023, 08:34 PM
Last Post: James D Jarvis
  Fastest image refresh TerryRitchie 2 823 03-06-2023, 11:18 PM
Last Post: TerryRitchie

Forum Jump:


Users browsing this thread: