Suppose I have a root controller MyViewController, with an instance variable 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?
The DEALLOC operation frees one previous allocation of heap storage. pointer-name is a pointer that must be the value previously set by a heap-storage allocation operation (either an ALLOC operation in RPG, or some other heap-storage allocation mechanism).
It's called when the reference count for that object becomes 0 because all its pointers have been released. The memory taken up by it is deallocated (freed); the object itself is destroyed.
-dealloc is an Objective-C selector that is sent by the Objective-C runtime to an object when the object is no longer owned by any part of the application. -release is the selector you send to an object to indicate that you are relinquishing ownership of that object.
Ans is NO Because with ARC no need to dealloc.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With