On Sun, Apr 18, 2021 at 8:13 PM Richard <richard.j.d.hug...@gmail.com> wrote:
>
> In the following sample code from: 
> https://v8.dev/docs/embed#accessing-dynamic-variables
>
> Point* p = ...;
> v8::Local<v8::Object> obj = point_templ->NewInstance();
> obj->SetInternalField(0, v8::External::New(isolate, p));
>
> Is there a way to know when `p` has been finished with? I would like to know 
> when/how to delete the allocated memory.

See v8::Global::SetWeak(), it lets you register a callback that's
invoked when the object is reclaimed by the garbage collector.

Caveat emptor, garbage collection is non-deterministic; it might
simply never run with short-lived scripts.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/CAHQurc9XBng33yztwtJNE9_J%3Dd3pWx4JdWrsNFrvWf0ReLmf2g%40mail.gmail.com.

Reply via email to