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.
精彩评论