Bradley, because you take a pointer to a stack allocated object which would be destroyed when you leave the block.
If you'd like to keep a reference to persistent (it won't work for local handles) the following trick should work: v8::Persistent<v8::Value> handle = ... void * payload = *handle; // ... v8::Persistent<v8::Value> restored_handle(reinterpret_cast<v8::Value*>(payload)); (warning: wasn't tested). yours, anton. On Tue, Jul 27, 2010 at 1:04 AM, bradley.meck <[email protected]> wrote: > I took a quick look at some simple collector functionality to have > some memory leaks in JS able to be resolved and am having trouble > finding out how to preserve Object references in the void* that > WeakCallbackReferences provide. I have made a gist of it. If someone > could explain why casting a pointer to a Persistent does not work, > that would be lovely. > > http://gist.github.com/491221 > > Cheers, > Bradley > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
