iPhone和iPod可用的最大运行时内存? [英] Maximum runtime memory available in iPhone and iPod?

查看:72
本文介绍了iPhone和iPod可用的最大运行时内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一种应用程序,其运行时内存可达6-7MB.当我运行该应用程序时,它运行良好,但有时会在设备上损坏或显示白屏,而不是实际视图.当我进行一些测试时,我知道它正在触发didRecieveMemoryWarning事件.

I am developing an applciation whose run time memory goes upto 6-7MB. When I run the application it works fine but sometimes it breaks on device or shows white screen instead of actual views. When I did some testing I came to know that it was triggering the didRecieveMemoryWarning event.

是图像的魅力所在,就像我正在使用很多动画一样,每次我调用图像动画函数来获取图像数组时,都会使用这些动画.由于我使用的是imageWithName,因此每次都需要调用.另外,由于我不拥有图像,因此不应该释放用于图像的内存.我认为这不是处理它的正确方法.有什么好的方法可以解决这个问题.有没有人有更好的主意,或者这不是问题.

Is it becoz of images, like I am using a lot of animation for which everytime I call the image animation function to get the array of the images. since I am using imageWithName, I need to call everytime. Also I am not supposed to release the memory used for the images as I dont own it. I think that this is not the right way to deal with it. Is there any good way to deal with this. do anyone have better idea or this is not the problem.

请注意,代码不会在模拟器上中断,而在代码之间也不会中断.

Please note that the code dont break on simulator wheras there is no breaking inbetween the code.

推荐答案

最大内存量将有所不同,可能会因许多因素而异.

The maximum amount of memory is going to vary, potentially significantly depending on a number of factors.

您不应真正地以设置的内存大小为目标,而应该从最大的低效率开始并向后工作,从而尽可能地优化代码中的每个字节.您可以使用Instruments中的ObjectAlloc工具来了解导致最大数量分配的原因.它还可以告诉您导致每次分配的调用顺序(堆栈).

You shouldn't really target a set size of memory as much as just optimize every byte out of your code you can, starting with the largest inefficiencies and working backwards. You can use the ObjectAlloc tool in Instruments to gain insight into what is responsible for the largest number of allocations. It can also tell you the sequence of calls -- the stack -- that led to each allocation.

我建议您研究一些CoreAnimation示例以获取更多信息,在此处禁止其他人提供有用的,具体的示例.

I'd suggest working through some of the CoreAnimation examples for more information, barring someone piping up with a useful, concrete, example here.

这篇关于iPhone和iPod可用的最大运行时内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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