Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Immediate memory release




On 30 Apr 2008, at 11:08 pm, Roland King wrote:
ok but why? I assume if this works that the NSImage alloc/ initWithContentsOfFile: is doing a retain/autorelease.

Of course that wouldn't violate the letter of the memory management documentation, which really just tells you that if you alloc/init an object, you are responsible for freeing it, I thought the spirit of it sort of implied that nobody else had retained/released the object and it wasn't sitting on someone's autorelease pool and as soon as you released it, it was gone.


Nothing in the docs says or implies this as far as I can see. I doubt if it's a safe assumption, not that it matters all that much - just follow the rules.


Given that NSImage is a complex beast, all sorts of internal temporary objects might be created and destroyed, or may temporarily retain the image and autorelease it. What you say may be true for simple objects, but in no case would I rely on it being true.

The bottom line is, release does not, and never has, meant "dealloc now" - it means "I'm no longer interested in you".


G.








On Apr 30, 2008, at 8:18 PM, 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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to 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: Roland King <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.