• 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
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: autorelease pool


  • Subject: Re: autorelease pool
  • From: "Erfan Aleemullah" <email@hidden>
  • Date: Tue, 23 Oct 2007 14:34:27 -0400

Yes, I am trying to figure out whether or not I need to use the release pool
and was throwing the above code out as an example - what I wanted to know is
**do I need the autorelease pool if the retain count is 1 after the command
[myObject release]; *
I need to deallocate memory in my program and release alone isn't taking the
retain count to 0
*
*
On 10/23/07, Mike Abdullah <email@hidden> wrote:
>
> In the code you've just posted, NSAutoreleasePool is not used in any
> way for your string.
>
> The sequence of alloc, init, and release does not use the autorelease
> pool since no -autorelease message is ever sent. Instead it does
> exactly as written:
>
> 1. Creates a new string object with a retain count of 1.
> 2. Releases the string so it has a retain count of 0.
> 3. Deallocates the memory used by the string since it has a retain
> count of 1.
>
> Mike.
>
> P.S. Normally in Cocoa you use lowercase to start a variable name. i.e.
>
> NSString *line
>
> On 23 Oct 2007, at 18:50, Erfan Aleemullah wrote:
>
> > I was wondering how this works and what happens if the retain count
> > reaches
> > 0 but the object wasn't part of a autorelease pool ?
> > *Example:*
> >
> > NS* String Line = [NSString alloc] init];
> >
> > .. random code ..
> >
> > [Line release];
> >
> > Now, what happens if the retain count is 1 and if its 0 for NSString
> > Line ?
> > ?
> >
> > How should I use an autorelease pool to actually deallocate the
> > memory used
> > by Line ?
> > _______________________________________________
> >
> > 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:
> @mikeabdullah.net
> >
> > This email sent to email@hidden
>
>
_______________________________________________

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

  • Follow-Ups:
    • Re: autorelease pool
      • From: Hank Heijink <email@hidden>
    • Re: autorelease pool
      • From: "Clark Cox" <email@hidden>
References: 
 >autorelease pool (From: "Erfan Aleemullah" <email@hidden>)
 >Re: autorelease pool (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: will/didChangeValueForKey: Real World Usage
  • Next by Date: Re: autorelease pool
  • Previous by thread: Re: autorelease pool
  • Next by thread: Re: autorelease pool
  • Index(es):
    • Date
    • Thread