[quickjs-devel] how to make an object survive gc...

  • From: Mario Gliewe <mag@xxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Sun, 15 Sep 2019 16:37:01 +0200

Hi,

I didn't dive deeper into the garbage collector yet..

I stumbled over the need to create a native object, which will not be
necessarily directly referenced by the globalThis of a context. So it
wont be marked on the MARK phase of the gc when just using globalThis as
a starting point.

Is it sufficient to just have a JSValue instance somewhere holding the
object, or will i have to manually ref() the object in some kind to
prevent the object becoming destroyed on gc()?

I noticed that in the gc_mark() of a timer (in quickjs-libc), the
callback function inside the JSOSTimer struct is explicitly mark()ed,
but how did the gc got to ask the timer object itself in the first place?

greets maG



Other related posts: