Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 4. Understanding Objective-C Mem... > Understanding What Memory Management...

4.4. Understanding What Memory Management Model to Use for Your Projects

Perhaps the most important thing to understand about garbage collection is when it's appropriate to be used and when it's not appropriate to be used. For certain, in many cases garbage collection is not a good choice for your application. As I've mentioned before, it's only available on MacOS X Versions 10.5, and later. If your code needs to run on any other platform, including iPhone or iPad, garbage collection isn't even an option for you. In addition to this, however, if you have an application that does not use garbage collection, and which has a large existing code base that is using reference counted memory management, it probably doesn't make sense to convert it to garbage collection. The effort required to do so may be prohibitive.

Finally, because the garbage collector is slightly less efficient with regard to how many objects are actively alive in the application at any given time, the deallocated objects aren't truly deallocated until the collector finds them. Additionally, the garbage collector itself must utilize CPU cycles in order to do its work. If either of these are a consideration for you, then using garbage collection in your application may not be an appropriate choice.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial