开发者

something about the dealloc method

Suppose I have a root controller MyViewController, with an instance vari开发者_运维百科able named var1. I assign a value to var1, yet I don't release it in dealloc method.

My question is what is it going to happen after the app exit?


From dealloc documentation...

Important: Note that 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. For this and other reasons, you should not manage scarce resources in dealloc—see “Object Ownership and Disposal” in Memory Management Programming Guide for more details.


The memory is reclaimed when the app exits. However, keep in mind your app is not exiting in recent versions of iOS unless the user terminates it or the OS terminates it for using too much memory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜