iOS:didReceiveMemoryWarning的有用性: [英] iOS: helpfulness of didReceiveMemoryWarning:

查看:236
本文介绍了iOS:didReceiveMemoryWarning的有用性:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的开发过程的一部分,用于跟踪崩溃和内存泄漏。作为一个策略,你把任何NSLog消息或一些这样的通知到 didReceiveMemoryWarning:?这种方法的文档相当稀疏。是准确的说,在崩溃发生之前,UIViewController会触发该方法吗?

I'm at the part of my development process for tracking down crashing and memory leaks. As a strategy, do you put any NSLog messages or notifications of some such into didReceiveMemoryWarning:? The documentation for this method is rather sparse. Is it accurate to say that before a crash will happen, the UIViewController will trigger that method? Is that a starting point before even going forward with Instruments?

推荐答案

确定,注意几件事:


  • didReceiveMemoryWarning将在内存崩溃之前调用。不是其他崩溃。如果您正确处理警告并释放内存,则可以避免内存不足的情况,而不会崩溃。

  • 您可以在模拟器中手动触发内存警告菜单。

  • 仪器可帮助您调试泄漏(虽然不是全部),但对崩溃并不是非常有用。

  • 不,我不个人使用NSLog - 我只是在调试时断开内存警告。

  • didReceiveMemoryWarning will be called before an out-of-memory crash. Not other crashes. If you handle the warning properly and free up memory, then you can avoid the out-of-memory condition and not crash.
  • You can manually trigger a memory warning in the simulator under the Hardware menu. Highly recommend doing this to test your handling of didReceiveMemoryWarning.
  • Instruments helps you debug leaks (though not all of them) - it's not really that useful for crashes.
  • No, I don't personally use NSLog - I just breakpoint the memory warnings when I'm debugging.

这篇关于iOS:didReceiveMemoryWarning的有用性:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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