• 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: [newbie] NSString code so it won't leak
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [newbie] NSString code so it won't leak


  • Subject: Re: [newbie] NSString code so it won't leak
  • From: Chris Ross <email@hidden>
  • Date: Wed, 11 Sep 2002 10:32:31 +0100

On Wednesday, September 11, 2002, at 05:26 am, Charles Srstka wrote:

On Tuesday, September 10, 2002, at 10:44 PM, Dean Davis wrote:


[snip]

What the hell?! I looked at the code, and it *should* crash. If it's not (and if the other one was leaking), then the autorelease pool isn't getting released, and that's really bizarre and should probably be reported as a bug.

However, if you enclose your code in these two lines:

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

// your code here

[pool release];


What happens to objects that are not ready to be released ?

Do they get given to the parent pool ?

Can I do this in the main loop of a thread to make sure memory
free'd up correctly whilst still retaining the objects I wish to keep?
By that I mean:

NSAutorealePool *pool = nil;

for( i = 0; i < SomeNumber; i++ )
{
pool = [[NSAutoreleasePool alloc] init];

..... main processing of the loop ....

[pool release];
}

If not, is there anyway to flush the pool so that objects do not build
up?

Regards,

Chris

--
Chris Ross - email@hidden - http://www.darkrock.co.uk
Ferite Programming Language - http://www.ferite.org
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: [newbie] NSString code so it won't leak
      • From: Shawn Erickson <email@hidden>
    • Re: [newbie] NSString code so it won't leak
      • From: Dietrich Epp <email@hidden>
References: 
 >Re: [newbie] NSString code so it won't leak (From: Charles Srstka <email@hidden>)

  • Prev by Date: Ignoring external monitors
  • Next by Date: Re: [newbie] NSString code so it won't leak
  • Previous by thread: Re: [newbie] NSString code so it won't leak
  • Next by thread: Re: [newbie] NSString code so it won't leak
  • Index(es):
    • Date
    • Thread