How to free memory associated with CGImageCreateWithImageInRect

I use CGImageCreateWithImageInRect()to create a small image from the runtime background image that will be displayed for each call flow (0.01 sec). As soon as I start showing part of the image with CGImageCreateWithImageInRect, the application will start consuming memory at a very high speed and will work within a few seconds. Memory consumption goes up to 20+ MB and crash. A regular application will run at 2 MB.

Image1 = CGImageCreateWithImageInRect(imageRef, CGRectMake(x, y, w, h));

and after processing I do

CGImageRelease(Image1);

but it does not help me.

I want to know how to release memory related to CGImageCreateWithImageInRect.

+3
source share
2 answers

- CGImageRelease; , , . - .

+4

, , CGImageCreateWithImageInRect() . ...

CGImageRef Image1 = CGImageCreateWithImageInRect(imageRef, CGRectMake(x, y, w, h));
CGImageRelease(imageRef);
...
CGImageRelease(Image1);
-1

Source: https://habr.com/ru/post/1705078/


All Articles