When exiting an App, do I have to release the pointers or is it done automatically?
When I exit out of an App, everything is released? Or if I have any pointer-arrays(malloc), do I have to release the pointers before exiting the App?
thanks开发者_运维知识库
This is not defined by the C specification (and thus not formally defined in Objective-C) but on iOS and all other modern operating systems, when a process terminates, its memory is returned to the system. So yes, any such pointers will be freed appropriately, though C++ destructors and Objective-C -dealloc
implementations will not be run.
Check out this stackoverflow post. All of your objects that still exist are just given back to the system and listed as free memory by the operating system.
As all other answers have noted, the answer is no. Interesting to note, however, is that in many cases you cannot deallocate memory, because the application has suddenly crashed. Barring any memory leaks in the OS itself, iOS will clean up the memory used by the application regardless of how it was allocated.
精彩评论