Re: Autorelease/Retain/Release
Re: Autorelease/Retain/Release
- Subject: Re: Autorelease/Retain/Release
- From: Michael Rothwell <email@hidden>
- Date: Sat, 28 Jul 2007 10:08:49 -0400
On Jul 25, 2007, at 12:00 PM, Bill Bumgarner wrote:
Namely: Do not design classes such that you are assuming that the
-dealloc will be invoked when you think it will be invoked. For
bug or valid reason, it might be delayed.
Specifically: Do not manage scarce resources in -dealloc and,
thus, manage scarce resources through reference counting. It is a
bad idea now and a fatal pattern under GC.
Design your classes such that you know when you are done with the
instances *and you tell them to be done*. At that point, the
objects can release scarce resources (file descriptors, network
connections, and buffers/caches, etc).
This very thing bit me in a past project, where I was trying to stop
an NSTimer inside dealloc. Weird bugs, strange crashes, etc., ensued.
Now I include a -stop or -finish method (or something similar) that
does the cleanup of resources like NSTimers. I still do some memory
deallocatons in dealloc, though.
_______________________________________________
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