• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: autorelease pool comprehension
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: autorelease pool comprehension


  • Subject: Re: autorelease pool comprehension
  • From: David Duncan <email@hidden>
  • Date: Wed, 30 Mar 2011 10:03:23 -0700

On Mar 30, 2011, at 9:53 AM, Apple Developer wrote:

> Why were the NSNumber objects not released when the pool was released?

In your example the numbers were added to an array that was then added to another object (list). Since each of these steps would normally retain the objects as well, until 'list' was released, none of the other objects would be as well.

> What am I doing wrong?

I don't think there is anything you are "doing" wrong, but you may need to refresh your understanding of retain-count based memory management. All an autorelease pool does is accumulate objects that will be released later. A release does not imply a deallocation, simply a relinquishing of ownership. If something else has a claim of ownership the object will not be released until that object gives up its claim, which is what is happening here.

Autorelease pools can be useful when you have a process which creates lots of objects that are otherwise short lived, but your particular case doesn't have that, since all of these objects end up being referenced, directly or indirectly, via the 'list' object.

--
David Duncan

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >autorelease pool comprehension (From: Apple Developer <email@hidden>)

  • Prev by Date: autorelease pool comprehension
  • Next by Date: Re: autorelease pool comprehension
  • Previous by thread: autorelease pool comprehension
  • Next by thread: Re: autorelease pool comprehension
  • Index(es):
    • Date
    • Thread