From: Carl Shapiro Date: Wed, 18 Aug 2010 01:33:56 +0000 (-0700) Subject: Fix a critical space leak introduced by concurrent sweeping. X-Git-Tag: android-x86-4.0-r1~298^2~131^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=e6a1b4dfc33732368bc6045501acd5e6e95f32a4;p=android-x86%2Fdalvik.git Fix a critical space leak introduced by concurrent sweeping. When computing the bitmaps for each heap, the live bitmap was assumed to have greater extent than the mark bitmap. With the concurrent sweep the mark and live bitmaps are swapped before the sweep bitmaps are computed. As such, the live bitmap extent is always less than or equal to the mark bitmap. A benchmark which loops creating objects just to drop them on the floor will exclude most objects in the heap as candidates for sweeping and will exhaust the heap. The change fixes the extent computation and reintroduces an assert to check that the bitmap we assume to be the largest is the largest. Change-Id: I78694d2a0550de70c85e2087d482050a147a207a --- diff --git a/vm/alloc/HeapSource.c b/vm/alloc/HeapSource.c index 8eac5cdbb..ed5f0815f 100644 --- a/vm/alloc/HeapSource.c +++ b/vm/alloc/HeapSource.c @@ -717,8 +717,9 @@ void dvmHeapSourceGetObjectBitmaps(HeapBitmap liveBits[], HeapBitmap markBits[], assert(numHeaps == hs->numHeaps); for (i = 0; i < hs->numHeaps; ++i) { base = (uintptr_t)hs->heaps[i].base; + assert(hs->markBits.max >= hs->liveBits.max); /* -1 because limit is exclusive but max is inclusive. */ - max = MIN((uintptr_t)hs->heaps[i].limit - 1, hs->liveBits.max); + max = MIN((uintptr_t)hs->heaps[i].limit - 1, hs->markBits.max); aliasBitmap(&liveBits[i], &hs->liveBits, base, max); aliasBitmap(&markBits[i], &hs->markBits, base, max); }