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
  • PrintPrint
Share this Page URL
Help

Chapter 24. Memory Management > Managed Memory Patterns

24.4. Managed Memory Patterns

The following sections show the basic programming patterns used when working in a managed memory environment. Some of these patterns have already been shown, but are included again for completeness and future reference.

24.4.1. New Object Patterns

When a new object is created it begins with a retain count of 1, implicitly making its creator the first owner. The principal messages that return new objects are: +alloc, +new, and -copy. This implied ownership must be balanced by a -release message when the object is no longer used, as shown in Listing 24-6, or an -autorelease message, as shown in Listing 24-7.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

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

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint