• 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: Sensible way to extend base class?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sensible way to extend base class?


  • Subject: Re: Sensible way to extend base class?
  • From: Michael Ash <email@hidden>
  • Date: Wed, 20 May 2009 19:37:49 -0400

On Wed, May 20, 2009 at 7:30 PM, Greg Parker <email@hidden> wrote:
> On May 20, 2009, at 4:11 PM, Michael Ash wrote:
>>
>> On Wed, May 20, 2009 at 4:35 PM, Greg Parker <email@hidden> wrote:
>>>
>>> It's also much harder under GC. The "obvious" solutions either leak
>>> (because the global table keeps stuff alive), or are thread-unsafe (because
>>> no amount of locks can save your dangling pointer if the collector decides
>>> to delete the object).
>>
>> Is there something wrong with using a [NSMapTable
>> mapTableWithWeakToStrongObjects] in that environment, with appropriate
>> synchronization, or do you just consider that to be non-obvious?
>
> It's much improved over the traditional "CFDictionary with non-retaining
> callbacks" scheme, but is still vulnerable to uncollectable cycles under GC,
> if I remember correctly. If a table-value can eventually point back to its
> table-key, then the objects will never be reclaimed because of the table's
> own strong reference to the table-value.

That would indeed cause trouble. I hadn't thought of that. That means
that it's fine if you're storing relatively simple auxiliary data but
it's not appropriate for arbitrary objects. Thanks for the info.

Mike
_______________________________________________

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

  • Follow-Ups:
    • Re: Sensible way to extend base class?
      • From: Louis Gerbarg <email@hidden>
References: 
 >Sensible way to extend base class? (From: Graham Cox <email@hidden>)
 >Re: Sensible way to extend base class? (From: Ken Thomases <email@hidden>)
 >Re: Sensible way to extend base class? (From: Greg Parker <email@hidden>)
 >Re: Sensible way to extend base class? (From: Michael Ash <email@hidden>)
 >Re: Sensible way to extend base class? (From: Greg Parker <email@hidden>)

  • Prev by Date: Re: Sensible way to extend base class?
  • Next by Date: Re: Tools in App Bundles
  • Previous by thread: Re: Sensible way to extend base class?
  • Next by thread: Re: Sensible way to extend base class?
  • Index(es):
    • Date
    • Thread