When to free an image?
#3
A whole lot of it depends on usage.

handle = _LOADIMAGE...
DO
    'Stuff
LOOP
END

With the above, you really don't have to worry about FreeImage.  load it once, use it for the whole program, then it'll free itself at program termination.  Honestly though, I'd probably still free it -- even if it isn't necessary before the END statement-- just to stay in good practice and never let lazy habits lead to issues elsewhere in the future.


DO
   handle = LOADIMAGE..
   'Stuff
LOOP
END

Now with the above here, you're going to have problems.  You're loading images repeatedly in the  DO LOOP, and you're never freeing them.  You, my friend, now have a massive memory leak and all the issues that arises from such!

Main module, inside a SUB, FUNCTION, or GOSUB...  The rule of thumb is simple -- when you're done with the image, just get in the habit of always freeing it.
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: 3 Guest(s)