Okay so does this mean that if you actually pass the handle back to js space then it does become eligible for GC? What you set it to a property of an object from js space?
I've been using the v8 API for a while now and I understand the basics (and a bit more). I'm just trying to make sure I understand this particular gotcha and how to avoid it. :Marco On Sat, Oct 23, 2010 at 6:40 PM, Rasmus Andersson <[email protected]> wrote: > On Sat, Oct 23, 2010 at 23:41, Marco Rogers <[email protected]> > wrote: > > Anton, what do you mean by "API functions.."? Which part of his above > > example are you referring to? I admit I'm still not sure what's wrong > > with what Rasmus is doing. > > I believe what Anton is saying is that an object created in C-land > will not be subject to GC. > > Here, we create (i.e. allocate) a Function object using the C++ API: > > HandleScope scope; > Local<Function> fun = Local<Function>::New(...); > Persistent<Function> phandle = Persistent<Function>::New(fun); > phandle.MakeWeak(data, &FinalizationCallback) > > If I understand Anton correctly, this function will never be garbage > collected thus FinalizationCallback never called. Anton, is that > correct? > > And the case v8 create the object for us: > > HandleScope scope; > Local<Value> v = EvalHelper("function(){}"); > Local<Function> fun = Local<Function>::Cast(v); > Persistent<Function> phandle = Persistent<Function>::New(fun); > phandle.MakeWeak(data, &FinalizationCallback) > > But in this case FinalizationCallback will be called. > > Is this correct? > > > -- Marco Rogers [email protected] Life is ten percent what happens to you and ninety percent how you respond to it. - Lou Holtz -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
