Commits (1)
  • Rob Swindell's avatar
    Perform a JS garbage collection for each new request in a reused session · 2e671622
    Rob Swindell authored
    A reused HTTP session would never (apparently) perform garbage collection.
    The evidence of this was the collection of concurrent user.dat file opens
    that would never close until the HTTP sessions were closed. Hundreds or
    even thousands of open user.dat's have been seen. After this change,
    active web server (webv4 UI) users have not caused these spikes in open
    user.dat files, at least in my testing.
    
    If no garbage collection was being performed, then likely a lot of JS
    heap was being needlessly wasted, which could eventually result in a JS
    "out of memory" error. But that's just a theory.
    
    Investigation is needed into why the js_CommonOperationCallback()'s calls to
    JS_MaybeGC() were not sufficient to actually perform garbage collection
    in this case.
    2e671622
......@@ -5868,8 +5868,10 @@ static BOOL js_setup_cx(http_session_t* session)
,NULL,NULL,JSPROP_READONLY|JSPROP_ENUMERATE);
JS_ENDREQUEST(session->js_cx);
}
else
else {
JS_BEGINREQUEST(session->js_cx);
JS_MaybeGC(session->js_cx);
}
lprintf(LOG_DEBUG,"%04d JavaScript: Initializing HttpRequest object",session->socket);
if(js_CreateHttpRequestObject(session->js_cx, session->js_glob, session)==NULL) {
......