[Question] How to properly store constructor for later use? #1197
-
I have some functions that would create an instance of my exported class, thus I need to get the ctor of it. I've tried to store it inside the context opaque, but this would cause object leak, as there's no callback to release the opaque itself (thus ctor got leak together). I've checked the samples, but |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Create a new class with |
Beta Was this translation helpful? Give feedback.
Create a new class with
JS_NewClass()
and give it gc_mark and finalizer functions, seeJSClassDef
. Mark the constructor in gc_mark (lets the GC know it's there) andJS_FreeValueRT
it in the finalizer.