iPhone内存管理: No Need to Clean Up and Release Retained Objects on App Quit?

标签 iphone objective-c memory-management cocos2d-iphone dealloc

下列说法正确吗?

When the app is about to quit, it's not necessary to clean up the memory by calling release on all your retained objects, because the iPhone OS will reclaim the memory it allocated for your app when you launched it. This is faster and safer than rely on the apps to correctly clean up after themselves. You can verify this by putting an NSLog call (or a debugger breakpoint) in the dealloc method of your application delegate and seeing it's never called.

So, cleaning things up when the app is about to quit is useless. Moreover, you have very limited time before the OS wipes your app out, so don't waste it on cleaning things. Focus on saving your game and any other relevant stuff.

Source (cocos2d-iphone.org)

最佳答案

是的。引用the documentation :

Important: When an application terminates, objects may not be sent a dealloc message since the process’s memory is automatically cleared on exit—it is more efficient simply to allow the operating system to clean up resources than to invoke all the memory management methods. This has implications for how you implement a dealloc method—see “Resource Management.”

关于iPhone内存管理: No Need to Clean Up and Release Retained Objects on App Quit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1571289/

相关文章:

ios - 如何添加 NSMutableArray 的总和

ios - AVPlayers 缓冲随着时间变慢

iphone - 当帖子中的链接被点击时,Facebook iPhone 应用程序打开 App Store 应用程序而不是网页

iphone - 特殊字符的 NSPredicate - iPhone

css - 丑陋的iphone滚动条,不可编辑

ios - 设置 viewcontroller bgcolor 时未绘制 ImageView 图像

memory-management - 为什么堆栈地址会朝着减少内存地址的方向增长?

objective-c - 为什么@1的保留计数等于7、8或10?

memory-management - 任何 iPhone 应用程序使用的内存

iphone - 检查 CoreData 属性是否为空