From 742ddb7979e0958adb1bb7944bf450da964df6a9 Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Sat, 6 Feb 2010 12:50:50 +0000 Subject: SCI: Run GC only when execution_stack_base is 0. svn-id: r47929 --- engines/sci/engine/vm.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 67f2fa13ea..a7aeecee05 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -569,8 +569,16 @@ static reg_t pointer_add(EngineState *s, reg_t base, int offset) { static void gc_countdown(EngineState *s) { if (s->gc_countdown-- <= 0) { - s->gc_countdown = script_gc_interval; - run_gc(s); + // Only run garbage collection when execution stack base + // is zero, as it cannot count references inside kernel + // functions + if (s->execution_stack_base == 0) { + s->gc_countdown = script_gc_interval; + run_gc(s); + } else { + // Try again later + s->gc_countdown = 1; + } } } -- cgit v1.2.3