• 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: Garbage collector vs variable lifetime
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Garbage collector vs variable lifetime


  • Subject: Re: Garbage collector vs variable lifetime
  • From: Quincey Morris <email@hidden>
  • Date: Fri, 6 Jun 2008 16:27:27 -0700


On Jun 6, 2008, at 15:48, Bill Bumgarner wrote:

The garbage collector does not currently interpret inner pointers as something that can keep an encapsulating object alive. Thus, the behavior is undefined and that it changes between debug and release builds -- between optimization levels of the compiler -- is neither surprising nor considered to be a bug.

Yes, it's certainly not the "inner" pointer's job to keep the object alive. I can't help feeling that it would make sense for the lifetime of the object pointer variable to be the same as its scope. (I have no idea if there's any language specification that deals with this.) If there's any compiler bug, it's the optimization that shortens the object pointer variable lifetime that's at fault.


In any case, you need to make sure that <data> stays alive throughout the entire lifespan of the bytes pointer.

But the puzzling question is: how? Anything involving stack variables could potentially be optimized away. I could move the collectable object pointer into a global or instance variable, but that solution comes unglued as soon as I hit a case where the containing method is called recursively. I suppose a file static NSMutableSet temporarily holding collectable objects would work.



_______________________________________________

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: Garbage collector vs variable lifetime
      • From: John Engelhart <email@hidden>
    • Re: Garbage collector vs variable lifetime
      • From: "Clark Cox" <email@hidden>
    • Re: Garbage collector vs variable lifetime
      • From: "Shawn Erickson" <email@hidden>
References: 
 >Garbage collector vs variable lifetime (From: Quincey Morris <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: Garbage collector vs variable lifetime
  • Next by Date: Re: Garbage collector vs variable lifetime
  • Previous by thread: Re: Garbage collector vs variable lifetime
  • Next by thread: Re: Garbage collector vs variable lifetime
  • Index(es):
    • Date
    • Thread