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

Re: Immediate memory release


  • Subject: Re: Immediate memory release
  • From: Graham Cox <email@hidden>
  • Date: Thu, 1 May 2008 10:53:41 +1000

If <some code> throws an exception won't that mean that <pool> is leaked? (and all of its contents up to that point too; applies to both of our code examples). Or is there some special handling of autorelease pools when an exception is thrown? If so, I wasn't aware of it - can you point to the relevant docs?

Genuinely trying to understand things better!

G.


On 30 Apr 2008, at 11:35 pm, email@hidden wrote:
Or you could go with:

-(IBAction) Generate:(id) sender
{
	for (i = 0; i < count; i++)
	{
	    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

NSImage* tempSource = [[[NSImage alloc] initWithContentsOfFile:sPath[i]] autorelease];
// autorelease tempSource to ensure that we get cleaned up if anything in 'some code' throws an exception.
// pool will automagically be released later if an exception does happen and [pool release] get bypassed.


		// some code

	    [pool release];
	}
}


Matt

On 30 Apr 2008, at 14:18, Graham Cox wrote:

-(IBAction) Generate:(id) sender
{
	for (i = 0; i < count; i++)
	{
	    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

NSImage* tempSource = [[NSImage alloc] initWithContentsOfFile:sPath[i]];
// some code
[tempSource release];

[pool release];
}
}


_______________________________________________

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: Immediate memory release
      • From: Jens Alfke <email@hidden>
References: 
 >Immediate memory release (From: Yannick De Koninck <email@hidden>)
 >Re: Immediate memory release (From: Graham Cox <email@hidden>)
 >Re: Immediate memory release (From: "Paul Bailey" <email@hidden>)
 >Re: Immediate memory release (From: Yannick De Koninck <email@hidden>)
 >Re: Immediate memory release (From: Graham Cox <email@hidden>)
 >Re: Immediate memory release (From: email@hidden)

  • Prev by Date: FSCopyObjectASync Not Calling Callback In Cocoa
  • Next by Date: Re: Trouble with NSPopUpButton and hierarchical menus?
  • Previous by thread: Re: Immediate memory release
  • Next by thread: Re: Immediate memory release
  • Index(es):
    • Date
    • Thread