Ok that sounds pretty simple. Is there a way to monitor it in-program as well, like by printing to the screen a list of loaded and freed images?
You might be able to monitor the image handles. Every image has an unique handle which we use to reference it in memory (
Handle = _LOADIMAGE(...stuff)).
I *believe* that the first image handle usually starts around -11 and increases by -1 for each image loaded after that. (I’m not at my PC currently, so I can’t test to be certain.)
So load one image, it’s handle value is usually -11. The next image handle value is -12. Then -13....
Free an image and those handles should be recycled when you load a new one.
First image loaded has a handle of -11. Second is -12. Third is -13....
Now, FREE the second image from memory (-12), LOAD a new image, and it *should* recycle that freed handle and have a value of -12...
So let’s say I’m loading up to 10 images in memory. IF I’m loading and freeing them properly, as simple check of something like this would make an easy warning:
SUB ValidateHandle (Handle AS LONG)
IF Handle < -100 THEN
CLS
PRINT “IMAGE MEMORY LEAK IN PROCESS!!”
END
END IF
END SUB
An endless loading and unloading of images would generate more than -100 handles, trip the IF, and report itself as an error for you.
**At least, I think it
should work. As I said above, I’m not at the PC currently for 100% testing.