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
[email protected]
http://groups.google.com/group/v8-users

Reply via email to