summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSangWook Han <swhan@nemustech.com>2012-05-11 20:58:01 +0900
committerelektroschmock <elektroschmock78@googlemail.com>2012-05-12 09:32:56 +0200
commita6cecb830d12f706138acd870abf0f4a73b31ffe (patch)
treea777404e1b4667a28a5ad17ce738a8ddefad10f6
parent909cbbb31eefcb00a43287eac2437c5342c27615 (diff)
downloadandroid_dalvik-a6cecb830d12f706138acd870abf0f4a73b31ffe.tar.gz
android_dalvik-a6cecb830d12f706138acd870abf0f4a73b31ffe.tar.bz2
android_dalvik-a6cecb830d12f706138acd870abf0f4a73b31ffe.zip
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
-rw-r--r--vm/alloc/Alloc.cpp1
-rw-r--r--vm/alloc/HeapSource.cpp5
-rw-r--r--vm/alloc/HeapSource.h5
3 files changed, 8 insertions, 3 deletions
diff --git a/vm/alloc/Alloc.cpp b/vm/alloc/Alloc.cpp
index d2c3336f8..ee2772757 100644
--- a/vm/alloc/Alloc.cpp
+++ b/vm/alloc/Alloc.cpp
@@ -302,6 +302,7 @@ void dvmCollectGarbage()
dvmLockHeap();
dvmWaitForConcurrentGcToComplete();
dvmCollectGarbageInternal(GC_EXPLICIT);
+ dvmHeapSourceTrimHeaps();
dvmUnlockHeap();
}
diff --git a/vm/alloc/HeapSource.cpp b/vm/alloc/HeapSource.cpp
index 6552680d8..4fc9a433f 100644
--- a/vm/alloc/HeapSource.cpp
+++ b/vm/alloc/HeapSource.cpp
@@ -35,7 +35,6 @@ extern "C" void dlmalloc_walk_free_pages(void(*)(void*, void*, void*), void*);
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 @@ static void *gcDaemonThread(void* arg)
if (!gDvm.gcHeap->gcRunning) {
dvmChangeStatus(NULL, THREAD_RUNNING);
if (trim) {
- trimHeaps();
+ dvmHeapSourceTrimHeaps();
gHs->gcThreadTrimNeeded = false;
} else {
dvmCollectGarbageInternal(GC_CONCURRENT);
@@ -1303,7 +1302,7 @@ static void releasePagesInRange(void *start, void *end, void *nbytes)
/*
* 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 66f2a6a21..749a34c84 100644
--- a/vm/alloc/HeapSource.h
+++ b/vm/alloc/HeapSource.h
@@ -154,6 +154,11 @@ size_t dvmHeapSourceGetIdealFootprint(void);
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.
*/