开发者

(iphone) UIImage memory management problem

I'm开发者_开发知识库 having trouble with UIImage memory management.

(iphone) my app gets memory warning when instruments shows "all allocations" only 7mb?

Essentially, I create/destroy UIImage many times.

Even if I make memory consumption at a time low using local NSAutoreleasePool, iphone/ipad device keeps complaining about memory usage.

I'm thinking, I should allocate UIImage to specific memory buffer(or pool of buffer) which I can designate to.

Is this possible?

Or any other suggestion on how to create/destroy UIImages many times without upsetting iOS would be much appreciated.

Thank you.


It is not a well known fact, but Instruments does not consider the size of UIImages within the allocated memory. You could be leaking 100Mb of UIImages and the allocated memory would not tell the story. What does tell the story is the number of live UIImage instances at a given moment.

In the Allocations instrument, using the top-right search box, search for "Image". Then look for the column labeled #linving in UIImage. That number is the number of UIImage objects. That is a better compass in to figuring out where are your UIImages going. If at some point you have more objects than what you expect, and thease UImages are not going away you have a UIImage leak in your hands. An UIImage leak will kill your app real fast.


CGImage doesn't fluctuate more than I think(max 6+).. umm maybe 6+ = 6mg and baseline 10mg = 16Mg triggered the warning

CGImages are not autoreleased, you should call CGImageRelease(image);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜