From: Carl Shapiro Date: Sat, 18 Sep 2010 00:10:48 +0000 (-0700) Subject: Ensure that an explicit GC request initiates a GC. X-Git-Tag: android-x86-4.0-r1~164^2~18^2~30 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=43c54c0b3a5161dedfee9c255e60788627ed8505;p=android-x86%2Fdalvik.git 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 --- 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(); }