--- a/webengine/osswebengine/MemoryManager/Src/MemoryManager.cpp Tue Feb 02 00:56:45 2010 +0200
+++ b/webengine/osswebengine/MemoryManager/Src/MemoryManager.cpp Fri Mar 19 09:52:28 2010 +0200
@@ -18,10 +18,9 @@
// INCLUDE FILES
-#include <MemoryManager.h>
+#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_LOGF(_L8("MemoryManager::CreateFastAllocator - s_pool=%x"), s_pool);
-#ifdef __NEW_ALLOCATOR__
- CMemoryPool *pool = new CNewSymbianHeapPool();
- pool->Create();
- RSymbianDlAllocatorWrapper* allocator = new RSymbianDlAllocatorWrapper((CNewSymbianHeapPool*)pool);
- MEM_LOGF(_L8("MemoryManager::CreateFastAllocator - new pool=%x, allocator=%x"), pool, allocator);
- User::SwitchAllocator(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);
+ __ASSERT_DEBUG( s_pool == 0, User::Panic( KMemManPanicDes, 0 ) );
#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,32 +78,6 @@
}
//-----------------------------------------------------------------------------
-// MemoryManager::InitOOMHandler
-//-----------------------------------------------------------------------------
-EXPORT_C void MemoryManager::InitOOMDialog()
- {
-#ifdef __NEW_ALLOCATOR__
- if (s_pool)
- {
- ((CNewSymbianHeapPool *)s_pool)->InitOOMDialog();
- }
-#endif
- }
-
-//-----------------------------------------------------------------------------
-// MemoryManager::ResetOOMDialogDisplayed
-//-----------------------------------------------------------------------------
-EXPORT_C void MemoryManager::ResetOOMDialogDisplayed()
- {
-#ifdef __NEW_ALLOCATOR__
- if (s_pool)
- {
- ((CNewSymbianHeapPool *)s_pool)->ResetOOMDialogDisplayed();
- }
-#endif
- }
-
-//-----------------------------------------------------------------------------
// MemoryManager::CloseFastAllocator
//-----------------------------------------------------------------------------
EXPORT_C void MemoryManager::CloseFastAllocator(RAllocator* aDefaultAllocator)
@@ -147,7 +96,6 @@
//-----------------------------------------------------------------------------
EXPORT_C void MemoryManager::AddCollector( MMemoryCollector* aCollector )
{
- MEM_LOGF(_L8("MemoryManager::AddCollector - s_pool=%x"), s_pool);
Pool()->AddCollector( aCollector );
}
@@ -164,7 +112,6 @@
//-----------------------------------------------------------------------------
EXPORT_C void MemoryManager::AddStopper( MOOMStopper* aStopper )
{
- MEM_LOGF(_L8("MemoryManager::AddStopper - s_pool=%x"), s_pool);
Pool()->AddStopper( aStopper );
}