English 中文(简体)
最好的方法来调试applicationDidReceiveMemoryWarning iPhone ?
原标题:
  • 时间:2009-03-20 16:42:45
  •  标签:

Need advice on how to debug this. I m new with limited environments and have no previous embedded or smart phone programming experience so I could use some clues. Already aware of: Instruments, Clanger Static Analysis, manual code review, etc. Instruments seems to be very helpful in general but quite time consuming and freezes up a lot of the time! Clanger has also helped me a lot as well. It seems like I m just consuming too much memory in general and I m wondering what a good strategy is. Do I release some top-level objects? Is there a preferred strategy ?

只是想知道是否有人解决这个成功,如果他们有任何其他建议吗?谢谢所有。

问题回答

有很多好的文章一个iPhone应用程序的内存管理。这里有一些有用的链接。

你应该照顾

  1. Release any variables which you do not need
  2. Always handle didReceiveMemoryWarning and release any variables not in use
  3. Stop any memory-heavy processes in applicationDidReceiveMemoryWarning like audio/video playing, UIImagePickerController etc

EDIT This does not apply any more. imageNamed: had caching issues prior to 3.x OS versions. The issue does not exist any more and you should use imageNamed: (makes implementing retina display easier)

  1. Do NOT use imageNamed: to create UIImage objects.

基本上你接收这个警告因为(毫无疑问)iPhone是危险的低内存。这通常可以为两个原因之一;

  1. You have a memory leak.
  2. You are allocating far too many objects and need to revisit your design.

第一你应该运行仪器和检查你的内存分配。这真的可以减缓你的应用程序(需要额外的内存)所以尝试测试你的应用领域之一。例如如果你有多个视图之间切换几次。

第二你必须检查你正在做的事情,可能会导致大的内存分配。例如如果你写Flickr浏览器您可能需要减少数量的图像加载在任何时间,或释放一些未使用的,当你收到这个警告。

这些是我唯一可以建议的一般规则不知道更多关于你的应用。

不幸的年代,没有真正的方式(我知道的)获得iPhone操作系统的当前内存分配数据。这使得它很难隔离区域无意中消耗大量内存的应用程序。





相关问题
热门标签