So I have this desktop app that uses GM(16)ImageMBS to load a rather big scan (> 10,000 x 6,000) and retrieve color patches and their histogram data from it. When this Image is loaded, I create a picture copy of it using GMImageMBS.CopyPicture and assign it to a private picture property of my test window. It will then be drawn to a Canvas and is being drawn on for a live update of the patch retrieval.
When all is done, user may load another GMImage and process can be repeated.
This is working nicely now, but when using Activity Monitor I saw the memory consumption of the app rise dramatically after each image processing. The JsonItem it builds as a result can be quite big, like > 80 MB, so some memory impact is to be expected. But not to climb to over 4 GB after just a few scans!
I used XojoInstruments to find the leak and, besides some minor short string leaks, found that the preview picture from the CopyPicture method is never released, causing the enormous memory appetite. What’s even more confusing: The picture is not referenced by anything according to Instruments. It simply will not get released. It was held in this private window picture property, and I tried to ObjC release it (crash for overrelease), CFRelease it (no change), Nil it before assigning a new value: No change at all! I tried to loop GMImageMBS.CopyPicture, thinking this could be the cause: No additional change in memory.
Any ideas what could be causing such a leak? @Christian_Schmitz in case this could be connected to GMImage somehow? The working image is similarly held in a private window property and replaced, without me seeing any leaks on it.