(iphone)UIImage内存管理问题 [英] (iphone) UIImage memory management problem

查看:107
本文介绍了(iphone)UIImage内存管理问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了UIImage内存管理问题。

(iphone)当乐器显示所有分配时,我的应用程序会收到内存警告只有7mb?

I'm having trouble with UIImage memory management.
(iphone) my app gets memory warning when instruments shows "all allocations" only 7mb?

基本上,我多次创建/销毁UIImage。

即使我使用低时使用内存消耗本地NSAutoreleasePool,iphone / ipad设备一直在抱怨内存使用情况。

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.

我在想,我应该将UIImage分配给我可以指定的特定内存缓冲区(或缓冲池)。

这是可能的吗? ?

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

或者有关如何多次创建/销毁UIImages而不会扰乱iOS的任何其他建议将非常感激。

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

谢谢。

推荐答案

这不是一个众所周知的事实,但是仪器没有考虑分配中的UIImages的大小记忆。你可能会泄漏100Mb的UIImages而且分配的内存不能说明这个故事。告诉故事的是在给定时刻的实时UIImage实例的数量。

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.

Allocations 工具中,使用右上角的搜索框搜索Image。然后在UIImage中查找标记为#linving的列。该数字是UIImage对象的数量。这是一个更好的指南针,可以确定你的UIImages在哪里。如果在某些时候你有更多的对象超过你的预期,并且你的UImage不会消失,你手中就会出现UIImage泄漏。 UIImage泄漏会快速杀死你的应用程序。

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.

这篇关于(iphone)UIImage内存管理问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆