OSDN Git Service

Fix: Issue 26627: Dalvik Heap Trim timer value after GC
authorSangWook Han <swhan@nemustech.com>
Fri, 11 May 2012 11:45:33 +0000 (20:45 +0900)
committerElliott Hughes <enh@google.com>
Fri, 11 May 2012 22:09:37 +0000 (15:09 -0700)
dvmRelativeCondWait need millisecods not seconds.

With this fix, trim will begins 5 seconds after concurrent GC

Bug: http://code.google.com/p/android/issues/detail?id=26627
Bug: 6482868
Change-Id: I3802b48e345725fb78e4ef2c999dd243ef30a138

vm/alloc/HeapSource.cpp

index f051b4d..2815577 100644 (file)
@@ -42,10 +42,10 @@ static void trimHeaps();
 #define HEAP_IDEAL_FREE             (2 * 1024 * 1024)
 #define HEAP_MIN_FREE               (HEAP_IDEAL_FREE / 4)
 
-/* Number of seconds to wait after a GC before performing a heap trim
+/* How long to wait after a GC before performing a heap trim
  * operation to reclaim unused pages.
  */
-#define HEAP_TRIM_IDLE_TIME_SECONDS 5
+#define HEAP_TRIM_IDLE_TIME_MS (5 * 1000)
 
 /* Start a concurrent collection when free memory falls under this
  * many bytes.
@@ -410,7 +410,7 @@ static void *gcDaemonThread(void* arg)
         bool trim = false;
         if (gHs->gcThreadTrimNeeded) {
             int result = dvmRelativeCondWait(&gHs->gcThreadCond, &gHs->gcThreadMutex,
-                    HEAP_TRIM_IDLE_TIME_SECONDS, 0);
+                    HEAP_TRIM_IDLE_TIME_MS, 0);
             if (result == ETIMEDOUT) {
                 /* Timed out waiting for a GC request, schedule a heap trim. */
                 trim = true;