From 43c54c0b3a5161dedfee9c255e60788627ed8505 Mon Sep 17 00:00:00 2001 From: Carl Shapiro Date: Fri, 17 Sep 2010 17:10:48 -0700 Subject: [PATCH] Ensure that an explicit GC request initiates a GC. Previously, if a concurrent GC was in-flight when an explicit GC was requested a warning would be logged about a recursive GC attempt. Now, the requesting thread will block until the GC is inactive and afterward initiate its foreground collection. Change-Id: Ibc4cef83315ffe7ccf822a32beb4cce5b1c816bd --- vm/alloc/Alloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vm/alloc/Alloc.c b/vm/alloc/Alloc.c index 02955bc68..4dcd91c65 100644 --- a/vm/alloc/Alloc.c +++ b/vm/alloc/Alloc.c @@ -295,9 +295,10 @@ void dvmReleaseTrackedAlloc(Object* obj, Thread* self) void dvmCollectGarbage(bool collectSoftReferences) { dvmLockHeap(); - + while (gDvm.gcHeap->gcRunning) { + dvmWaitForConcurrentGcToComplete(); + } dvmCollectGarbageInternal(collectSoftReferences, GC_EXPLICIT); - dvmUnlockHeap(); } -- 2.11.0