From 3becac5769f5af05be4cc033ab24924f4bd3458c Mon Sep 17 00:00:00 2001 From: Christopher Lenz Date: Sat, 29 Mar 2008 00:15:02 +0000 Subject: Remove branch limit and fix memory leak in Javascript view server. Fixes issue COUCHDB-25. git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@642448 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_js.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/couchdb/couch_js.c b/src/couchdb/couch_js.c index a234fda9..8481bc50 100644 --- a/src/couchdb/couch_js.c +++ b/src/couchdb/couch_js.c @@ -335,12 +335,12 @@ ReadLine(JSContext *context, JSObject *obj, uintN argc, jsval *argv, jsval *rval JS_free(context, chars); return JS_FALSE; } + JS_free(context, bytes); chars[charslen] = '\0'; /* Initialize a JSString object */ str = JS_NewUCString(context, chars, charslen - 1); if (!str) { - JS_free(context, bytes); JS_free(context, chars); return JS_FALSE; } @@ -386,15 +386,10 @@ ExecuteScript(JSContext *context, JSObject *obj, const char *filename) { } static uint32 gBranchCount = 0; -static uint32 gBranchLimit = 100 * 1024; static JSBool BranchCallback(JSContext *context, JSScript *script) { - if (++gBranchCount == gBranchLimit) { - gBranchCount = 0; - return JS_FALSE; - } - if ((gBranchCount & 0x3fff) == 1) { + if ((++gBranchCount & 0x3fff) == 1) { JS_MaybeGC(context); } return JS_TRUE; -- cgit v1.2.3