1

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

Kristen Martinson
  • 1,829
  • 3
  • 22
  • 33

3 Answers3

0

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.

Jonathan Grynspan
  • 43,286
  • 8
  • 74
  • 104
  • Sorta -- pointers will *not* be freed. The entire virtual address space of the app (and the physical resources used in relation) are simply returned to the system. Nothing at the pointer level happens at all. – bbum Jul 21 '11 at 06:24
  • Eh, that's a subtlety I was skipping over, but yes, you're right. – Jonathan Grynspan Jul 21 '11 at 12:56
0

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.

Community
  • 1
  • 1
Carter
  • 3,053
  • 1
  • 17
  • 22
0

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.

Dan Rosenstark
  • 68,471
  • 58
  • 283
  • 421