@@ -30,6 +30,7 @@ typedef struct g_proxy_execute_jsc_s {
3030 JSCValue * (* jsc_context_evaluate )(JSCContext * context , const char * code , gssize length );
3131 JSCException * (* jsc_context_get_exception )(JSCContext * context );
3232 void (* jsc_context_set_value )(JSCContext * context , const char * name , JSCValue * value );
33+ void (* jsc_context_garbage_collect )(JSCContext * , bool sanitize_stack );
3334 // Value functions
3435 gboolean (* jsc_value_is_string )(JSCValue * value );
3536 gboolean (* jsc_value_is_number )(JSCValue * value );
@@ -190,8 +191,11 @@ bool proxy_execute_jsc_get_proxies_for_url(void *ctx, const char *script, const
190191 g_object_unref (functions [i ].value );
191192 }
192193
193- if (global )
194+ if (global ) {
195+ if (g_proxy_execute_jsc .jsc_context_garbage_collect )
196+ g_proxy_execute_jsc .jsc_context_garbage_collect (global , false);
194197 g_object_unref (global );
198+ }
195199
196200 return is_ok ;
197201}
@@ -262,6 +266,10 @@ void proxy_execute_jsc_delayed_init(void) {
262266 g_proxy_execute_jsc .jsc_context_set_value = dlsym (g_proxy_execute_jsc .module , "jsc_context_set_value" );
263267 if (!g_proxy_execute_jsc .jsc_context_set_value )
264268 goto jsc_init_error ;
269+ // JS_EXPORT_PRIVATE void jscContextGarbageCollect(JSCContext*, bool sanitizeStack = false) is undocumented, may be
270+ // unavailable, and is not declared with C language linkage.
271+ g_proxy_execute_jsc .jsc_context_garbage_collect =
272+ dlsym (g_proxy_execute_jsc .module , "_Z24jscContextGarbageCollectP11_JSCContextb" );
265273 // Value functions
266274 g_proxy_execute_jsc .jsc_value_is_string = dlsym (g_proxy_execute_jsc .module , "jsc_value_is_string" );
267275 if (!g_proxy_execute_jsc .jsc_value_is_string )
0 commit comments