CGImageCreateWithImageInRect

CGImageCreateWithImageInRect

本文介绍了如何释放由CGImageCreateWithImageInRect关联的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 CGImageCreateWithImageInRect()从背景图像运行时生成一个小图像,该图像将在每次线程调用时显示(0.01秒)。一旦我开始通过 CGImageCreateWithImageInRect 应用程序显示图像的一部分,就会开始以很高的速度消耗内存并在几秒钟内崩溃。消耗的内存超过20 MB,并且崩溃。普通应用程序将在2MB上运行。

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.

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

,经过处理后,我会这样做

and after processing I do

CGImageRelease(Image1);

但这对我没有帮助。

我想知道如何释放与 CGImageCreateWithImageInRect 相关的内存。

I want to know how to release memory associated with CGImageCreateWithImageInRect.

推荐答案

您问题的答案实际上是CGImageRelease;您从代码中摘录的那对线是正确平衡的。您一定是在其他地方泄漏。

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.

这篇关于如何释放由CGImageCreateWithImageInRect关联的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 19:44