Trim after explicit gc.

  On Gingerbread, dvmHeapSourceTrim() is called 5 seconds
  after every kind of GC. Current AOSP do trim only for
  concurrent GC. That makes OOM killer too busy.

  At least explicit GC need trim and in case of explicit
  GC, there are no need to delay 5 seconds before trim.

Change-Id: I8fde8f773398bf20c674cfa6f686d7d745d56492
diff --git a/vm/alloc/Alloc.cpp b/vm/alloc/Alloc.cpp
index d2c3336..ee27727 100644
--- a/vm/alloc/Alloc.cpp
+++ b/vm/alloc/Alloc.cpp
@@ -302,6 +302,7 @@
     dvmLockHeap();
     dvmWaitForConcurrentGcToComplete();
     dvmCollectGarbageInternal(GC_EXPLICIT);
+    dvmHeapSourceTrimHeaps();
     dvmUnlockHeap();
 }
 
diff --git a/vm/alloc/HeapSource.cpp b/vm/alloc/HeapSource.cpp
index 6552680..4fc9a43 100644
--- a/vm/alloc/HeapSource.cpp
+++ b/vm/alloc/HeapSource.cpp
@@ -35,7 +35,6 @@
 static void snapIdealFootprint();
 static void setIdealFootprint(size_t max);
 static size_t getMaximumSize(const HeapSource *hs);
-static void trimHeaps();
 
 #define HEAP_UTILIZATION_MAX        1024
 #define DEFAULT_HEAP_UTILIZATION    512     // Range 1..HEAP_UTILIZATION_MAX
@@ -428,7 +427,7 @@
         if (!gDvm.gcHeap->gcRunning) {
             dvmChangeStatus(NULL, THREAD_RUNNING);
             if (trim) {
-                trimHeaps();
+                dvmHeapSourceTrimHeaps();
                 gHs->gcThreadTrimNeeded = false;
             } else {
                 dvmCollectGarbageInternal(GC_CONCURRENT);
@@ -1303,7 +1302,7 @@
 /*
  * Return unused memory to the system if possible.
  */
-static void trimHeaps()
+void dvmHeapSourceTrimHeaps()
 {
     HS_BOILERPLATE();
 
diff --git a/vm/alloc/HeapSource.h b/vm/alloc/HeapSource.h
index 66f2a6a..749a34c 100644
--- a/vm/alloc/HeapSource.h
+++ b/vm/alloc/HeapSource.h
@@ -154,6 +154,11 @@
 void dvmHeapSourceGrowForUtilization(void);
 
 /*
+ * Return unused memory to the system if possible.
+ */
+void dvmHeapSourceTrimHeaps();
+
+/*
  * Walks over the heap source and passes every allocated and
  * free chunk to the callback.
  */