Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does dealloc method being executed normally when quitting the application?

I use code like the following (inside my appController.m for example) to do some cleanup when my application terminates...

- (void) dealloc {
    [myObject release]; // myObject 's dealloc will not be called either !!!
    [arraySMSs release];
    [super dealloc];
}

This method never get called when the app quits! Why ? Is there a better place to do my clean up ? The fact that is not called addresses memory-leak issues ? Or the OS does take care of clean up ?

Thank you...

like image 946
Vassilis Avatar asked Dec 06 '22 23:12

Vassilis


1 Answers

There is no reason for the system to ensure that every object is individually deallocated upon application termination.

Doing so is just a waste of CPU cycles and a waste of the user's time.

When an app is terminated, all resources used by that app are reclaimed by the system in an entirely automatic and unavoidable fashion.

If you need something to happen at app termination, use the application delegate's hooks for doing so. But don't rely on that. A user may force reboot a device or force quit an application at whim.

like image 160
bbum Avatar answered May 20 '23 16:05

bbum