Hi Ian,
To delete user data on GC you need to create a weak persistent handle for
your External. A user supplied callback function would be invoked on GC of
this weak Persistent, and you can delete your data there, like this:
MethodDescriptor* md = new MethodDescriptor();
Local<External> ext = External::New(isolate, md);
Persistent<External> pext(isolate, ext);
pext.SetWeak(data, [](v8::WeakCallbackData<External, MethodDescriptor>
const& data)
{
MethodDescriptor* md = data.GetParameter();
delete md;
});
Function::New(isolate, callback, External::New(isolate, md))
Note that GC could be called some time later (even it could)
On Tuesday, March 15, 2016 at 12:15:10 AM UTC+3, Ian Bull wrote:
>
> I'm creating a Function with a C++ callback as follows:
>
> MethodDescriptor* md = new MethodDescriptor();
>
> md -> someFields = someValue;
>
> Function::New(isolate, callback, External::New(isolate, md))
>
>
> In this case I associate a MethodDescriptor (md) with the function so that
> when my callback is invoked I can get information about this particular
> instance. How can I get notified (via a callback or destructor) that this
> Function has been GC'd so I can clean-up the memory I allocated for the
> MethodDescriptor?
>
--
--
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.