• 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: Efficient object wrappers and GC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Efficient object wrappers and GC


  • Subject: Re: Efficient object wrappers and GC
  • From: "Michael Ash" <email@hidden>
  • Date: Fri, 11 Apr 2008 11:07:55 -0400

On Fri, Apr 11, 2008 at 6:04 AM, Alastair Houghton
<email@hidden> wrote:
>  Under GC, these kinds of tricks are no longer possible because there is no
> -retain call any more, so no way to tell if it is safe to re-initialise and
> return the same wrapper object.
>
>  Aside from re-implementing the data structure itself in ObjC and making all
> of its nodes objects, which might not be possible in some cases, has anyone
> thought of an efficient solution to this problem when running under GC?

The obvious technique would be to stop trying to make the optimization
implicit and to make it explicit and managed by the caller instead. In
other words, you write your API so that it explicitly returns the same
object every time you call -nextObject, just with a new state. Then
you have a copy method which the caller can use to get a new
unchanging object for the case where he wants to keep one around.

Unfortunately questions like "does anyone have a reference to this
object", while answerable, are too expensive to ask on a regular basis
under GC. The GC gets efficiency by asking this question on a bulk
basis once a bunch of objects have built up. Doing it for one object
in a tight loop would completely destroy whatever efficiency you're
gaining, and a whole lot more besides.

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: Efficient object wrappers and GC
      • From: Alastair Houghton <email@hidden>
    • Re: Efficient object wrappers and GC
      • From: Quincey Morris <email@hidden>
References: 
 >Efficient object wrappers and GC (From: Alastair Houghton <email@hidden>)

  • Prev by Date: Re: Tips to deploy applications to multiple Mac OS X versions
  • Next by Date: Re: Tips to deploy applications to multiple Mac OS X versions
  • Previous by thread: Efficient object wrappers and GC
  • Next by thread: Re: Efficient object wrappers and GC
  • Index(es):
    • Date
    • Thread