Hi, I have code as : v8::Persistent <v8::Context> context = v8::Context::New( NULL, orderTemplate );
v8::Handle <v8::Script> script = v8::Script::Compile( source ); v8::Persistent <v8::Script > per_script = v8::Persistent<v8::Script>::New(script ); I store the persistent handle-> context and per_script. Later in my allication, i retrive the above and try to run the script as follows: context->Enter(); per_script->Run(); context->Exit(); The above three statements try to retrive the object from the persistent handle and then run the script. This has a lot of overhead in terms of performance (Time taken to run the function) . How would this problem be solved? On Friday, February 10, 2012 2:54:05 AM UTC+5:30, Guy X. Smiley wrote: > Context::New() returns a persistent handle. See v8.h. > > On Feb 9, 3:35 pm, cruisercoder <[email protected]> wrote: > > > Yep, looks good, except I still think you'll leak the context (see my > > > message above). > > > BTW, I think "Persistent<Context>::New(Context::New())" creates > > > two persistent handles. To avoid a leak, I think you just want > > > to do "context = Context::New()". > > > > All the examples that I see suggest that Context::New() creates a > > local handle that is disposed on HandleScope exit and that > > Persistent<X>:New(h) makes a persistent copy of the handle passed to > > it: > > > > http://create.tpsitulsa.com/wiki/V8/Persistent_Handles -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
