CET 3510
Monday, May 18, 2015
Memory Management on OS X and iOS
The history of virtual memory on Mac OS and its faults.
Allocation and deallocation of memory through pointers
The end of dealloc, retain, and release calls on iOS
Automatic Reference Counting in OS X and iOS
Memory management is the act of dynamically allocating memory to different programs as it is requested and freeing it when it is no longer needed. The goal of any memory management system is the reduce a program’s memory footprint. OS X and iOS accomplish this through object ownership.
Object ownership is implemented through what is called a reference-counting system. This system tracks how many owners an object has, and in turn increases an object’s reference count for every time an owner claims ownership. When you are finished with the object, the reference count is decreased. When the reference count is above 0, the object is guaranteed and allowed to exist, but when it reaches 0, the operating system is allowed to destroy it and deallocate the memory. …show more content…
To do this, you have to free, or release the memory when it is no longer in use. If you free the memory while it is still in use or it is needed, this can lead to a program crashing or corrupting user data. If you don’t free memory that is no longer in use, it can cause what is called a memory leak. A memory is when allocated memory isn’t freed even though it is never used again. It causes your program to use an increasing amount of memory and may eventually lead to poor system