• 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: Autorelease/Retain/Release
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Autorelease/Retain/Release (From: Tim Davis <email@hidden>)
 >Re: Autorelease/Retain/Release (From: Nick Zitzmann <email@hidden>)
 >Re: Autorelease/Retain/Release (From: Tim Davis <email@hidden>)
 >Re: Autorelease/Retain/Release (From: mmalc crawford <email@hidden>)
 >Re: Autorelease/Retain/Release (From: Charlton Wilbur <email@hidden>)
 >Re: Autorelease/Retain/Release (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Gradient NSOutlineView row - Text color of it's NSTextFieldCell
  • Next by Date: How can I add persistent data to a Cocoa CoreData file?
  • Previous by thread: Re: Autorelease/Retain/Release
  • Next by thread: C++ framework
  • Index(es):
    • Date
    • Thread