ppdelegate的dealloc中释放ivars有什么意义吗

ppdelegate的dealloc中释放ivars有什么意义吗

本文介绍了在appdelegate的dealloc中释放ivars有什么意义吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在dealloc方法中释放appdelegate的ivars可能是一个很好的做法,但实际上它是否有任何意义?

I know that probably it's a good practice to release appdelegate's ivars in its dealloc method, but practically, does it makes any sence?

据了解,当应用程序运行时,iPhone应用程序的appdlegate将生存在内存中,所有内存将在关闭时被释放。

As I understand the appdelegate of an iPhone app will live in memory while the application is running and all memory will be freed anyway when it's closed.

谢谢

推荐答案

良好的内存管理应该是一种习惯。你必须考虑的时间和地点越多,就越有可能犯错误。这可能是单独的理由。

Good memory management should be a habit. The more you have to think about when and where it applies the more likely you are to make mistakes. That may be reason enough alone to do it.

翻转问题 - 添加这些版本会失去什么?添加它们真的很努力吗?

Flip the question around - what do you lose by adding those releases? Is it really much effort to add them?

还有一些问题:


  • 如果架构有所改变,应用程序委托提前发布会怎么样?

  • 如果其中一个被释放的对象在其dealloc中进行了额外的清理(例如保存其状态)(忽略一下这是否是一个好主意)。

  • 当您建立&分析?

个人我做所有我的应用程序委托版本。你可以认为这是不值得的 - 但是我希望给你一些理由,否则考虑。

Personally I do all my app delegate releases. You could argue that it's not worth it - but I hope I've given you some reasons to consider otherwise.

[更新]

我曾经介绍过可能存在相关的替代内存管理技术 - 使用(通过Objective-C ++)!

I've since blogged about an alternative memory management technique that may be relevant - using (via Objective-C++) smart pointers!

这篇关于在appdelegate的dealloc中释放ivars有什么意义吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 18:26