Locally scoped version of persistent is almost equivalent to Local except that Local can never be weak.
> Local<Context> lcontext = pcontext; It should be Local<Context> lcontext = Local<Context>::New(pcontext); -- Vyacheslav Egorov On Fri, Apr 6, 2012 at 3:32 AM, Marcel Laverdet <mar...@laverdet.com> wrote: > Hey I'm wondering why there isn't a helper class for Persistent<T> which > will Dispose() a handle at the end of scope. It seems like right now v8 > encourages lots of unfriendly cleanup code such as: > > void function hello() { > Persistent<Thing> thing = Persistent<Thing>::New(...); > ... > thing.Dispose(); > } > > This kind of code is difficult to maintain in many cases, and also > vulnerable to memory leaks when using C++ exceptions. I'd like to see a > version of Persistent<T> that behaves similarly to std::unique_ptr<T>. v8 > already has helper classes like this with Isolate::Scope and Context::Scope. > > Or perhaps there's a way to get what I want with local handles? I tried > something like this to no avail: > > Persistent<Context> pcontext = Context::New(NULL, global); > Local<Context> lcontext = pcontext; > pcontext.Dispose(); > > Any advise would be appreciated! > > -- > v8-users mailing list > v8-users@googlegroups.com > http://groups.google.com/group/v8-users -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users