diff -r e1bea15f9a39 -r 79859ed3eea9 webengine/osswebengine/MemoryManager/Src/heap.cpp --- a/webengine/osswebengine/MemoryManager/Src/heap.cpp Thu Aug 19 10:58:56 2010 +0300 +++ b/webengine/osswebengine/MemoryManager/Src/heap.cpp Tue Aug 31 16:17:46 2010 +0300 @@ -17,8 +17,6 @@ */ #include "common.h" -#include "StopScheduler.h" -#include #ifdef TRACE_CHUNK_USAGE void TraceChunkUsage(TInt aChunkHandle, TUint8* aBase, TInt aChunkSize) @@ -32,7 +30,7 @@ #ifdef __NEW_ALLOCATOR__ #include "MemoryLogger.h" -#include "SymbianDLHeap.h" +#include "SymbianDlHeap.h" _LIT(KDLHeapPanicCategory, "DL Heap"); #define GET_PAGE_SIZE(x) UserHal::PageSizeInBytes(x) @@ -265,22 +263,20 @@ } iPageSize = 0; iFlags = aSingleThread ? (ESingleThreaded|EFixedSize) : EFixedSize; - isLowSystemMemory = 0; Init(0, 0, 0); } UEXPORT_C RSymbianDLHeap::RSymbianDLHeap(TInt aChunkHandle, TInt aOffset, TInt aMinLength, TInt aMaxLength, TInt aGrowBy, TInt aAlign, TBool aSingleThread) - : iMinLength(aMinLength), iMaxLength(aMaxLength), iOffset(aOffset), iChunkHandle(aChunkHandle), - iAlign(aAlign), iNestingLevel(0), iAllocCount(0), iFailType(ENone), iTestData(NULL), iChunkSize(aMinLength) + : iMinLength(aMinLength), iMaxLength(aMaxLength), iOffset(aOffset), iChunkHandle(aChunkHandle), iNestingLevel(0), iAllocCount(0), + iAlign(aAlign),iFailType(ENone), iTestData(NULL), iChunkSize(aMinLength) { // TODO: Locked the page size to 4 KB - change this to pick up from the OS GET_PAGE_SIZE(iPageSize); __ASSERT_ALWAYS(aOffset >=0, User::Panic(KDLHeapPanicCategory, ETHeapNewBadOffset)); iGrowBy = _ALIGN_UP(aGrowBy, iPageSize); iFlags = aSingleThread ? ESingleThreaded : 0; - isLowSystemMemory = 0; // Initialise // if the heap is created with aMinLength==aMaxLength then it cannot allocate slab or page memory @@ -661,7 +657,7 @@ return chunk2mem(v); } } - //CORRUPTION_ERROR_ACTION(m); + CORRUPTION_ERROR_ACTION(m); } return 0; } @@ -707,8 +703,8 @@ return chunk2mem(v); } } - //CORRUPTION_ERROR_ACTION(m); - //return 0; + CORRUPTION_ERROR_ACTION(m); + return 0; } inline void RSymbianDLHeap::init_top(mstate m, mchunkptr p, size_t psize) @@ -799,7 +795,7 @@ return newmem; } } - //return 0; + return 0; } /* ----------------------------- statistics ------------------------------ */ mallinfo RSymbianDLHeap::internal_mallinfo(mstate m) { @@ -812,7 +808,7 @@ size_t mfree = m->topsize + TOP_FOOT_SIZE; size_t sum = mfree; msegmentptr s = &m->seg; - // TInt tmp = (TUint8*)m->top - (TUint8*)s->base; + TInt tmp = (TUint8*)m->top - (TUint8*)s->base; while (s != 0) { mchunkptr q = align_as_chunk(s->base); chunkCnt++; @@ -844,11 +840,13 @@ void RSymbianDLHeap::internal_malloc_stats(mstate m) { if (!PREACTION(m)) { + size_t maxfp = 0; size_t fp = 0; size_t used = 0; check_malloc_state(m); if (is_initialized(m)) { msegmentptr s = &m->seg; + maxfp = m->max_footprint; fp = m->footprint; used = fp - (m->topsize + TOP_FOOT_SIZE); @@ -1740,7 +1738,7 @@ return mem; } - //return 0; + return 0; } void RSymbianDLHeap::dlfree(void* mem) { @@ -1829,9 +1827,9 @@ else { size_t nsize = chunksize(next); - //int next_chunk_unmapped = 0; + int next_chunk_unmapped = 0; if( page_not_in_memory(next, nsize) ) { - // next_chunk_unmapped = 1; + next_chunk_unmapped = 1; unmapped_pages += ((tchunkptr)next)->npages; } @@ -2300,24 +2298,9 @@ // otherwise commit the pages specified // { - // Check for min threshold in system RAM to be left free - TInt sysFreeRAM = 0; - if(HAL::Get(HALData::EMemoryRAMFree, sysFreeRAM) == KErrNone) - { - if(sysFreeRAM < KStopThreshold) // 1MB - return 0; - - // check system memory level - if(sysFreeRAM < KGoodMemoryThreshold) - isLowSystemMemory = 1; - else - isLowSystemMemory = 0; - } - - - ASSERT(p == floor(p, pagesize)); - ASSERT(sz == ceiling(sz, pagesize)); - ASSERT(sz > 0); +ASSERT(p == floor(p, pagesize)); +ASSERT(sz == ceiling(sz, pagesize)); +ASSERT(sz > 0); if (iChunkSize + sz > iMaxLength) return 0; @@ -2361,16 +2344,9 @@ { // need to allocate-copy-free void* newp = map(0, sz); - if(newp) - { - memcpy(newp, p, oldsz); - unmap(p,oldsz); - return newp; - } - else - { - return 0; - } + memcpy(newp, p, oldsz); + unmap(p,oldsz); + return newp; } } return p;