04-13-2023, 05:02 PM
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.
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.