Questions around Object::Wrap/Unwrap and GC/finalizers on isolate shutdown?

9 views
Skip to first unread message

jmr

unread,
Jul 8, 2025, 6:55:58 PMJul 8
to v8-users
Hi,

I guess these questions would be better place in some sort of chat platform, as I might have more, but here they go, never the less.

The documentation for Object::Wrap/Unwrap seems quite thin, are there any good code examples on how to use this correctly?

I looks like this is just a nicer api for embedders than Set/GEtInternalField, but it's not obvious how to use the type tags?

Separate question around finalizers.
Currently I track c++ object lifetime with:
if (class_spec->destructor)
{
    v8::Global<v8::Object> global_handle(isolate, obj);
    global_handle.SetWeak(native_ptr, class_spec->destructor, v8::WeakCallbackType::kParameter);
}

and the destructor is type aware, casts the void* behind native_ptr to the correct type and deletes it.

Do these fire when the isolate is shut down?
Doesn't look like it.
How do I get the isolate to fire all finalizers on termination to make sure all C++ objects are cleaned up?

My project creates quite a lot of short lived isolates which it might terminate, and I want to make sure they (and the object behind them) are cleaned up correctly,.

Thanks.
Reply all
Reply to author
Forward
0 new messages