On Tue, Jan 19, 2021 at 12:26 PM Vinayaka Kamath
<vinayaka.kam...@couchbase.com> wrote:
>
> It seems like the v8 is crashing when I follow this. To add more to what I am 
> trying to do, when the "value" goes out of scope I want it to get garbage 
> collected and in the callback, I am freeing up resources held by the value. I 
> am basically forcing GC using isolate->LowMemoryNotification() only when I am 
> creating a new item that holds the same type of resource as of that of 
> "value". I've ensured that I'm calling LowMemoryNotification() in the same 
> thread as that of persistent->setWeak(). However one of the threads running 
> the process is crashing.

Not a direct answer to your question but it sounds like you're
approaching this wrong. The garbage collector is not a good mechanism
for deterministic resource management.

I also get the impression that you have the wrong idea what "weak"
means here: it's not weak in the sense that it's immediately eligible
for collection, only when there are no strong references (and only
when the garbage collector feels like it - V8's GC is very lazy.)

If your JS code is the functional equivalent of `globalThis.value =
create()`, then you can call LowMemoryNotification() all you want but
it's never going to get collected.

-- 
-- 
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/CAHQurc-zG5uYJ1_tSjod5rBJJzrbDqoLkwSoPs9m-1%2BFrOvwhg%40mail.gmail.com.

Reply via email to