Commit 64a1ca3e authored by rswindell's avatar rswindell
Browse files

Executs static JS services in a private "scope", to force GC of local objects

upon loop.
parent 4a099183
......@@ -972,6 +972,7 @@ static void js_static_service_thread(void* arg)
SOCKET socket;
/* JavaScript-specific */
JSObject* js_glob;
JSObject* js_scope;
JSScript* js_script;
JSRuntime* js_runtime;
JSContext* js_cx;
......@@ -1020,15 +1021,19 @@ static void js_static_service_thread(void* arg)
js_script=JS_CompileFile(js_cx, js_glob, spath);
if((js_scope=JS_NewObject(js_cx, NULL, NULL, js_glob))==NULL) {
lprintf("%04d !JavaScript FAILED to create scope object", service->socket);
if(js_script==NULL) {
if((js_script=JS_CompileFile(js_cx, js_scope, spath))==NULL) {
lprintf("%04d !JavaScript FAILED to compile script (%s)",service->socket,spath);
JS_ExecuteScript(js_cx, js_glob, js_script, &rval);
JS_ExecuteScript(js_cx, js_scope, js_script, &rval);
JS_DestroyScript(js_cx, js_script);
JS_ClearScope(js_cx, js_scope);
} while(!service->terminated && service->options&SERVICE_OPT_STATIC_LOOP);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment