diff options
Diffstat (limited to 'vm/alloc/HeapSource.cpp')
-rw-r--r-- | vm/alloc/HeapSource.cpp | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/vm/alloc/HeapSource.cpp b/vm/alloc/HeapSource.cpp index 0f97e201f..e01ee06c8 100644 --- a/vm/alloc/HeapSource.cpp +++ b/vm/alloc/HeapSource.cpp @@ -33,7 +33,17 @@ static void setIdealFootprint(size_t max); static size_t getMaximumSize(const HeapSource *hs); static void trimHeaps(); +#ifdef DALVIK_LOWMEM +static const bool lowmem = true; +#else +static const bool lowmem = false; +#endif + #define HEAP_UTILIZATION_MAX 1024 +#define DEFAULT_HEAP_UTILIZATION 512 // Range 1..HEAP_UTILIZATION_MAX +#define HEAP_IDEAL_FREE_DEFAULT (2 * 1024 * 1024) +static unsigned int heapIdeaFree = HEAP_IDEAL_FREE_DEFAULT; +#define HEAP_MIN_FREE ((heapIdeaFree) / 4) /* How long to wait after a GC before performing a heap trim * operation to reclaim unused pages. @@ -410,13 +420,24 @@ static bool addNewHeap(HeapSource *hs) overhead, hs->maximumSize); return false; } - size_t morecoreStart = MAX(SYSTEM_PAGE_SIZE, gDvm.heapStartingSize); - heap.maximumSize = hs->growthLimit - overhead; - heap.concurrentStartBytes = hs->minFree - concurrentStart; - heap.base = base; - heap.limit = heap.base + heap.maximumSize; - heap.brk = heap.base + morecoreStart; - heap.msp = createMspace(base, morecoreStart, hs->minFree); + + if(lowmem) { + heap.maximumSize = hs->growthLimit - overhead; + heap.concurrentStartBytes = HEAP_MIN_FREE - concurrentStart; + heap.base = base; + heap.limit = heap.base + heap.maximumSize; + heap.brk = heap.base + HEAP_MIN_FREE; + heap.msp = createMspace(base, HEAP_MIN_FREE, hs->maximumSize - overhead); + } + else { + size_t morecoreStart = MAX(SYSTEM_PAGE_SIZE, gDvm.heapStartingSize); + heap.maximumSize = hs->growthLimit - overhead; + heap.concurrentStartBytes = hs->minFree - concurrentStart; + heap.base = base; + heap.limit = heap.base + heap.maximumSize; + heap.brk = heap.base + morecoreStart; + heap.msp = createMspace(base, morecoreStart, hs->minFree); + } if (heap.msp == NULL) { return false; } @@ -643,14 +664,16 @@ fail: bool dvmHeapSourceStartupAfterZygote() { - //For each new application forked, we need to reset softLimit and - //concurrentStartBytes to be the correct expected value, not the one - //inherit from Zygote - HeapSource* hs = gHs; - - hs->softLimit=SIZE_MAX; - hs->heaps[0].concurrentStartBytes = mspace_footprint(hs->heaps[0].msp) - concurrentStart; - return gDvm.concurrentMarkSweep ? gcDaemonStartup() : true; + if(lowmem) { + return gDvm.concurrentMarkSweep ? gcDaemonStartup() : true; + } + else { + HeapSource* hs = gHs; + + hs->softLimit=SIZE_MAX; + hs->heaps[0].concurrentStartBytes = mspace_footprint(hs->heaps[0].msp) - concurrentStart; + return gDvm.concurrentMarkSweep ? gcDaemonStartup() : true; + } } /* |