Hi All,
I working in a add-on for Node.js, and i have the following problem:
class A {
local<object> CreateObject( callback) {
if(!p->isEmpty()){
auto tmp = Object::New(Isolate, objTemplate); //get from cache.
return tmp->newInstance(); //we have a template, create a instance.
}
/* create object here and assign callback {x:callback[function]} */
objTemplate.Reset(Isolate, obj); //cache here.
return obj->newInstance();.
}
~A(){
objTemplate.Reset();
}
private:
Persistent<ObjectTemplate> objTemplate;
}
/* NativeFunction declared here will be linked to obj methods created by A
*/
A a;
void MakeObject(functionCallbackInfo args){
args->GetReturn().Set(a.CreateObject(NativeFunction))
}
Javascript
Enter code here...
(function(){
for(var i=0; i<1000; i++) {
// this call MakeObject in C++.
var tmp = make_object(); // tmp => {n:[function],....};
}
})
I just want to cache the Object members using a template, cause i find that
it was way slower to make the object from scratch, problem is that when the
VM finish i got a SIGSEGV Segmentation fault,
I'm assume this is because of GC, so I add the cleaning function in the
desctructor but not luck, the only way to avoid the SIGSEGV is to delete
the object way before exit.
I'm thinking to use Eternal<>, but just wanted to know if this is not a
good use case for Persistent? Is a more elegant way to solve this problem
? or I'm doing something wrong.
Thanks.
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.