Skip to Main Content
Objective-C® For Dummies®
book

Objective-C® For Dummies®

by Neal Goldstein
October 2009
Beginner content levelBeginner
456 pages
8h 59m
English
For Dummies
Content preview from Objective-C® For Dummies®

Chapter 13. Getting a Handle on Memory Management

In This Chapter

  • Understanding memory management

  • Finding potential memory leaks

  • Managing memory

  • Memory management for arrays and autoreleased objects

  • Using the garbage collector

  • Knowing the important memory management rules

In Chapter 12, I explain about object allocation and initialization. You start with alloc and init. It is alloc, if you remember, that sets aside some memory for the object and returns back a pointer to that memory. This is important to keep in mind, because once you create these new objects, you become responsible for managing them.

Managing the memory allocated for your objects can be one of the few real hassles in programming with Objective-C. And although a new feature in Objective-C 2.0, garbage collection, makes Mac OS X programming easier, it isn't available on the iPhone. But a word to the wise: Even if you want to program the Mac using only Objective-C 2.0 and garbage collection, read through this chapter anyway because it really will help solidify your understanding of pointers and objects and what gets passed when you include objects as arguments in messages.

Warning

Memory management is not glamorous, but it trumps cool in an application. In fact, memory management is probably the single most vexing thing about iPhone and Mac programming. It has made countless programmers crazy, and I can't stress enough how important it is to build memory management into your code from the start. Take it from me, retrofitting ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Objective-C

Objective-C

Jiva DeVoe
Cocoa in a Nutshell

Cocoa in a Nutshell

Michael Beam, James Duncan Davidson

Publisher Resources

ISBN: 9780470522752Purchase book