Using the createCopy() command it is leaking memory. If you check “getReferenceCount()” on the copy it is 2. Here is a code snippet":
Image getSmallerImage(File file){
Image img = ImageFileFormat::loadFrom(file);
Rectangle r (…);
Image retImage = img.getClippedImage®.createCopy();//Needed to get rid of reference to larger image
//Here a retImage.getReferenceCount() = 2;
return retImage;
}
Without the createCopy, all works great except that I am using way too much memory as I only need a small part of each large image. The leak detector also reports the leaks in CoreGraphicsImage.
Sure, this would work too, but the OP was reporting a genuine bug. And now that I’ve fixed the bug, his original clone() version is the best way to do this task.