Re: Guidelines for Cocoa frameworks supporting garbage collection?
Re: Guidelines for Cocoa frameworks supporting garbage collection?
- Subject: Re: Guidelines for Cocoa frameworks supporting garbage collection?
- From: "Sean McBride" <email@hidden>
- Date: Mon, 7 Jul 2008 13:30:30 -0400
- Organization: Rogue Research
On 7/5/08 2:56 PM, Chris Hanson said:
>For example, this pseudocode is wrong under GC:
>
> - (NSURL *)someURL {
> NSURL *URL = (NSURL *)CFURLCreate...(...);
> return [URL autorelease];
> }
>
>It will leak, because the runtime will "eat" the -autorelease message
>when running under GC.
Which reminds me of something else Bill might want to watch out for:
Apple's leak finding tools ('leaks', Instruments, Malloc Debug) do not
work with GC apps. They report so many false positives that they are
unworkable (except for Malloc Debug, which just crashes). So if your
code uses malloc/new/NewPtr of whatever, you'll have a hard time finding
leaks.
Also, I second the recommendation to stay away from finalize. I've used
it exactly twice: 1) to call DisposeHandle() to 2) to call NSLog.
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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