Re: Garbage collector vs variable lifetime
Re: Garbage collector vs variable lifetime
- Subject: Re: Garbage collector vs variable lifetime
- From: "Hamish Allan" <email@hidden>
- Date: Sat, 7 Jun 2008 00:18:16 +0100
On Fri, Jun 6, 2008 at 11:48 PM, Bill Bumgarner <email@hidden> wrote:
> The garbage collector does not currently interpret inner pointers as
> something that can keep an encapsulating object alive.
But it's not the inner pointers I would expect to keep the object
alive -- it's the fact that stack variables are root objects, and that
NSData *data is still in the current stack frame.
>From http://developer.apple.com/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcEssentials.html
:
"The initial root set of objects is comprised of global variables,
stack variables, and objects with external references. These objects
are never considered as garbage. The root set is comprised of all
objects reachable from root objects and all possible references found
by examining the call stacks of every Cocoa thread."
If the optimising compiler is marking variables past a certain point
in the code block as being collectable because it doesn't think
they're going to be used again before the stack frame is popped, this
should be made explicit in the documentation (perhaps it is but I
missed it).
And is it really that important of an optimisation to make, if it's
going to have side effects like this?
Hamish
_______________________________________________
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