From ce3f003e467781f55ceed2ad5accd7b6f212f93a Mon Sep 17 00:00:00 2001 From: Adel Gadllah Date: Fri, 21 May 2010 23:25:41 +0200 Subject: [PATCH] Call shell_global_maybe_gc() when no work is being done Call shell_global_maybe_gc when idle when no other work is ongoing to free up memory and improve performance by preventing the GC to kick in at less convenient times. See: https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_MaybeGC https://bugzilla.gnome.org/show_bug.cgi?id=614725 --- src/shell-global.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/shell-global.c b/src/shell-global.c index 11f0ee4b0..47ac928f0 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -1484,6 +1484,16 @@ run_leisure_functions (gpointer data) if (global->work_count > 0) return FALSE; + /* + * We do call MAYBE_GC() here to free up some memory and + * prevent the GC from running when we are busy doing other things. + */ + shell_global_maybe_gc (global); + + /* No leisure closures, so we are done */ + if (global->leisure_closures == NULL) + return FALSE; + closures = global->leisure_closures; global->leisure_closures = NULL; @@ -1550,7 +1560,7 @@ shell_global_end_work (ShellGlobal *global) g_return_if_fail (global->work_count > 0); global->work_count--; - if (global->work_count == 0 && global->leisure_closures != NULL) + if (global->work_count == 0) schedule_leisure_functions (global); }