diff -r e1bea15f9a39 -r 79859ed3eea9 webengine/osswebengine/MemoryManager/Src/MemoryManager.cpp --- a/webengine/osswebengine/MemoryManager/Src/MemoryManager.cpp Thu Aug 19 10:58:56 2010 +0300 +++ b/webengine/osswebengine/MemoryManager/Src/MemoryManager.cpp Tue Aug 31 16:17:46 2010 +0300 @@ -18,10 +18,9 @@ // INCLUDE FILES -#include +#include "MemoryManager.h" #include "MemoryPool.h" #include "FastAllocator.h" -#include "MemoryLogger.h" // CONSTANTS @@ -32,6 +31,16 @@ // initializing a global memory pool. static CMemoryPool *s_pool = 0; +struct cleanupMemoryPool { + ~cleanupMemoryPool() { + if(s_pool) + { + delete s_pool; + s_pool = NULL; + } + } +}; +static cleanupMemoryPool deleteMemoryPool; //----------------------------------------------------------------------------- // Pool() - a utility function for accessing the right memory pool @@ -49,50 +58,16 @@ } //----------------------------------------------------------------------------- -// MemoryManager::CreateAllocator -//----------------------------------------------------------------------------- -EXPORT_C void MemoryManager::CreateFastAllocator() - { - // create the right memory pool - MEM_LOG_CREATE(); -#ifdef __NEW_ALLOCATOR__ - CMemoryPool *pool = new CNewSymbianHeapPool(); - pool->Create(); - RSymbianDlAllocatorWrapper* allocator = new RSymbianDlAllocatorWrapper((CNewSymbianHeapPool*)pool); - User::SwitchAllocator(allocator); - MEM_LOGF(_L8("MemoryManager::CreateFastAllocator - new pool=%x, allocator=%x"), pool, allocator); -#endif - } - -//----------------------------------------------------------------------------- -// MemoryManager::InitAllocator -//----------------------------------------------------------------------------- -EXPORT_C void MemoryManager::InitFastAllocator() - { - // Initialize s_pool variable from current allocator, assumption is that main program has already called CreateAllocator() - // It is special case when this allocator is created in SetupThreadHeap() where can not initialize static data. It also - // solves problems due to static data destruction in Symbian 9.5. -#ifdef __NEW_ALLOCATOR__ - RAllocator &aAllocator = User::Allocator(); - RSymbianDlAllocatorWrapper* allocator = (RSymbianDlAllocatorWrapper*) &aAllocator; - s_pool = allocator->iPool; - MEM_LOGF(_L8("MemoryManager::InitFastAllocator - s_pool=%x, allocator=%x"), s_pool, allocator); -#endif - } - -//----------------------------------------------------------------------------- // MemoryManager::SwitchToFastAllocator //----------------------------------------------------------------------------- EXPORT_C RAllocator* MemoryManager::SwitchToFastAllocator() { // create the right memory pool __ASSERT_DEBUG( s_pool == 0, User::Panic( KMemManPanicDes, 0 ) ); - MEM_LOGF(_L8("MemoryManager::SwitchToFastAllocator - s_pool=%x"), s_pool); #ifdef __NEW_ALLOCATOR__ s_pool = new CNewSymbianHeapPool(); s_pool->Create(); RSymbianDlAllocatorWrapper* allocator = new RSymbianDlAllocatorWrapper((CNewSymbianHeapPool*)s_pool); - MEM_LOGF(_L8("MemoryManager::SwitchToFastAllocator - new s_pool=%x"), s_pool); return User::SwitchAllocator( allocator ); #else s_pool = new CFastMemoryPool(); @@ -103,28 +78,6 @@ } //----------------------------------------------------------------------------- -// MemoryManager::InitOOMHandler -//----------------------------------------------------------------------------- -EXPORT_C void MemoryManager::InitOOMDialog() - { -#ifdef __NEW_ALLOCATOR__ - if (s_pool) - s_pool->InitOOMDialog(); -#endif - } - -//----------------------------------------------------------------------------- -// MemoryManager::ResetOOMDialogDisplayed -//----------------------------------------------------------------------------- -EXPORT_C void MemoryManager::ResetOOMDialogDisplayed() - { -#ifdef __NEW_ALLOCATOR__ - if (s_pool) - s_pool->ResetOOMDialog(); -#endif - } - -//----------------------------------------------------------------------------- // MemoryManager::CloseFastAllocator //----------------------------------------------------------------------------- EXPORT_C void MemoryManager::CloseFastAllocator(RAllocator* aDefaultAllocator) @@ -242,11 +195,3 @@ return Pool()->MemorySize( aPtr ); } - -EXPORT_C void MemoryManager::DumpMemoryLogs() - { -#if defined(OOM_LOGGING) && defined (__NEW_ALLOCATOR__) - CNewSymbianHeapPool *hPool = (CNewSymbianHeapPool *)Pool(); - hPool->DumpHeapLogs(0); -#endif - }