CGImageCreateWithImageInRect
returns a CGImageRef with a retain count of +1. So you must release the recevied CGImageRef.
CGImageRelease(pauseImgBg);
in the end. Try and read the documentation when you have the time. It will help you to isolate these kinds of cases. From documentation
Core Foundation functions have names that indicate when you own a returned object:
- Object-creation functions that have “Create” embedded in the name
- Object-duplication functions that have “Copy” embedded in the name.
If you own an object, it is your responsibility to relinquish ownership when you have finished with it.
And from the documentation of CGImageCreateWithImageInRect itself
The resulting image retains a reference to the original image, which means you may release the original image after calling this function.