OSDN Git Service

Fix a critical space leak introduced by concurrent sweeping.
authorCarl Shapiro <cshapiro@google.com>
Wed, 18 Aug 2010 01:33:56 +0000 (18:33 -0700)
committerCarl Shapiro <cshapiro@google.com>
Wed, 18 Aug 2010 01:47:47 +0000 (18:47 -0700)
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

vm/alloc/HeapSource.c

index 8eac5cd..ed5f081 100644 (file)
@@ -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);
     }