• 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: dealloc for cleanup versus freeing memory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dealloc for cleanup versus freeing memory


  • Subject: Re: dealloc for cleanup versus freeing memory
  • From: Chris Suter <email@hidden>
  • Date: Tue, 7 Aug 2007 09:06:34 +1000


On 07/08/2007, at 4:07 AM, John Stiles wrote:

I feel as if you remove all the benefits of reference counting if you add a specific "cleanup" method. If some other method had retained the object for some reason, what is it supposed to do now?
Explicit cleanup mechanisms only seem to work if you want an object that can't be copied or shared at all, and you give up all the benefits of refcounting for what don't appear to be very solid benefits (basically, things "work better" even if you accidentally leak an object).

The built-in reference counting should only really be used for managing the lifetime of the object in memory. If you want a resource such as a file handle to be reference counted you should reference count that separately. An object might persist in memory in different states. A file object, for example, might be open or closed and you don't want to tie that to whether it exists in memory. You probably want to ensure that when it's not in memory, the file is closed, but you might also want the file closed whilst the object remains in memory.


- Chris

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: 
 >Re: dealloc for cleanup versus freeing memory (From: Kurt Bigler <email@hidden>)
 >Re: dealloc for cleanup versus freeing memory (From: Chris Suter <email@hidden>)
 >Re: dealloc for cleanup versus freeing memory (From: John Stiles <email@hidden>)

  • Prev by Date: Re: Turning off sorting for one column of an NStableView
  • Next by Date: Cocoaheads Lake Forest 92630 meeting TOMORROW, tuesday 9/7
  • Previous by thread: Re: dealloc for cleanup versus freeing memory
  • Next by thread: Re: dealloc for cleanup versus freeing memory
  • Index(es):
    • Date
    • Thread