I am using CGImageCreateWithImageInRect()
for generating a small image from a background image runtime, which is going to displayed for every thread call (0.01 sec). Once I start showing part of image through CGImageCreateWithImageInRect
application starts consuming memory in very high rate and crashes within seconds. Memory consumed goes to 20+ MB and crashes. Normal application would run on 2MBs.
我正在使用CGImageCreateWithImageInRect()来从后台图像运行时生成一个小图像,它将显示给每个线程调用(0.01秒)。一旦我开始通过CGImageCreateWithImageInRect应用程序显示图像的一部分,它就会以非常高的速度消耗内存,并在几秒钟内崩溃。内存消耗达到20+ MB并崩溃。正常的应用程序将在2MBs上运行。
Image1 = CGImageCreateWithImageInRect(imageRef, CGRectMake(x, y, w, h));
and after processing I do
经过处理后,我做了
CGImageRelease(Image1);
but it is not helping me.
但这对我没有帮助。
I want to know how to release memory associated with CGImageCreateWithImageInRect
.
我想知道如何释放与CGImageCreateWithImageInRect相关的内存。
2 个解决方案
#1
4
The answer to your question is in fact CGImageRelease; the pair of lines you have excerpted from your code are correctly balanced. You must be leaking somewhere else.
你的问题的答案实际上是CGImageRelease;您从代码中摘录的这两行是正确平衡的。你一定是从别的地方漏的。
#2
-1
Actually, that pair of lines are not balanced, since CGImageCreateWithImageInRect() retains the original image. It should be…
实际上,这对行并不均衡,因为CGImageCreateWithImageInRect()保留了原始图像。它应该是……
CGImageRef Image1 = CGImageCreateWithImageInRect(imageRef, CGRectMake(x, y, w, h));
CGImageRelease(imageRef);
...
CGImageRelease(Image1);
#1
4
The answer to your question is in fact CGImageRelease; the pair of lines you have excerpted from your code are correctly balanced. You must be leaking somewhere else.
你的问题的答案实际上是CGImageRelease;您从代码中摘录的这两行是正确平衡的。你一定是从别的地方漏的。
#2
-1
Actually, that pair of lines are not balanced, since CGImageCreateWithImageInRect() retains the original image. It should be…
实际上,这对行并不均衡,因为CGImageCreateWithImageInRect()保留了原始图像。它应该是……
CGImageRef Image1 = CGImageCreateWithImageInRect(imageRef, CGRectMake(x, y, w, h));
CGImageRelease(imageRef);
...
CGImageRelease(Image1);