56 |
57 |
57 return s_pool; |
58 return s_pool; |
58 } |
59 } |
59 |
60 |
60 //----------------------------------------------------------------------------- |
61 //----------------------------------------------------------------------------- |
|
62 // MemoryManager::CreateAllocator |
|
63 //----------------------------------------------------------------------------- |
|
64 EXPORT_C void MemoryManager::CreateFastAllocator() |
|
65 { |
|
66 // create the right memory pool |
|
67 MEM_LOGF(_L8("MemoryManager::CreateFastAllocator - s_pool=%x"), s_pool); |
|
68 #ifdef __NEW_ALLOCATOR__ |
|
69 CMemoryPool *pool = new CNewSymbianHeapPool(); |
|
70 pool->Create(); |
|
71 RSymbianDlAllocatorWrapper* allocator = new RSymbianDlAllocatorWrapper((CNewSymbianHeapPool*)pool); |
|
72 MEM_LOGF(_L8("MemoryManager::CreateFastAllocator - new pool=%x, allocator=%x"), pool, allocator); |
|
73 User::SwitchAllocator(allocator); |
|
74 #endif |
|
75 } |
|
76 |
|
77 //----------------------------------------------------------------------------- |
|
78 // MemoryManager::InitAllocator |
|
79 //----------------------------------------------------------------------------- |
|
80 EXPORT_C void MemoryManager::InitFastAllocator() |
|
81 { |
|
82 // Initialize s_pool variable from current allocator, assumption is that main program has already called CreateAllocator() |
|
83 // It is special case when this allocator is created in SetupThreadHeap() where can not initialize static data. It also |
|
84 // solves problems due to static data destruction in Symbian 9.5. |
|
85 #ifdef __NEW_ALLOCATOR__ |
|
86 RAllocator &aAllocator = User::Allocator(); |
|
87 RSymbianDlAllocatorWrapper* allocator = (RSymbianDlAllocatorWrapper*) &aAllocator; |
|
88 s_pool = allocator->iPool; |
|
89 MEM_LOGF(_L8("MemoryManager::InitFastAllocator - s_pool=%x, allocator=%x"), s_pool, allocator); |
|
90 #endif |
|
91 } |
|
92 |
|
93 //----------------------------------------------------------------------------- |
61 // MemoryManager::SwitchToFastAllocator |
94 // MemoryManager::SwitchToFastAllocator |
62 //----------------------------------------------------------------------------- |
95 //----------------------------------------------------------------------------- |
63 EXPORT_C RAllocator* MemoryManager::SwitchToFastAllocator() |
96 EXPORT_C RAllocator* MemoryManager::SwitchToFastAllocator() |
64 { |
97 { |
65 // create the right memory pool |
98 // create the right memory pool |
66 __ASSERT_DEBUG( s_pool == 0, User::Panic( KMemManPanicDes, 0 ) ); |
99 //__ASSERT_DEBUG( s_pool == 0, User::Panic( KMemManPanicDes, 0 ) ); |
|
100 MEM_LOGF(_L8("MemoryManager::SwitchToFastAllocator - s_pool=%x"), s_pool); |
67 #ifdef __NEW_ALLOCATOR__ |
101 #ifdef __NEW_ALLOCATOR__ |
68 s_pool = new CNewSymbianHeapPool(); |
102 s_pool = new CNewSymbianHeapPool(); |
69 s_pool->Create(); |
103 s_pool->Create(); |
70 RSymbianDlAllocatorWrapper* allocator = new RSymbianDlAllocatorWrapper((CNewSymbianHeapPool*)s_pool); |
104 RSymbianDlAllocatorWrapper* allocator = new RSymbianDlAllocatorWrapper((CNewSymbianHeapPool*)s_pool); |
|
105 MEM_LOGF(_L8("MemoryManager::SwitchToFastAllocator - new s_pool=%x"), s_pool); |
71 return User::SwitchAllocator( allocator ); |
106 return User::SwitchAllocator( allocator ); |
72 #else |
107 #else |
73 s_pool = new CFastMemoryPool(); |
108 s_pool = new CFastMemoryPool(); |
74 s_pool->Create(); |
109 s_pool->Create(); |
75 RFastAllocator* allocator = new RFastAllocator((CFastMemoryPool*)s_pool); |
110 RFastAllocator* allocator = new RFastAllocator((CFastMemoryPool*)s_pool); |
94 //----------------------------------------------------------------------------- |
129 //----------------------------------------------------------------------------- |
95 // MemoryManager::AddCollector |
130 // MemoryManager::AddCollector |
96 //----------------------------------------------------------------------------- |
131 //----------------------------------------------------------------------------- |
97 EXPORT_C void MemoryManager::AddCollector( MMemoryCollector* aCollector ) |
132 EXPORT_C void MemoryManager::AddCollector( MMemoryCollector* aCollector ) |
98 { |
133 { |
|
134 MEM_LOGF(_L8("MemoryManager::AddCollector - s_pool=%x"), s_pool); |
99 Pool()->AddCollector( aCollector ); |
135 Pool()->AddCollector( aCollector ); |
100 } |
136 } |
101 |
137 |
102 //----------------------------------------------------------------------------- |
138 //----------------------------------------------------------------------------- |
103 // MemoryManager::RemoveCollector |
139 // MemoryManager::RemoveCollector |
110 //----------------------------------------------------------------------------- |
146 //----------------------------------------------------------------------------- |
111 // MemoryManager::AddStopper |
147 // MemoryManager::AddStopper |
112 //----------------------------------------------------------------------------- |
148 //----------------------------------------------------------------------------- |
113 EXPORT_C void MemoryManager::AddStopper( MOOMStopper* aStopper ) |
149 EXPORT_C void MemoryManager::AddStopper( MOOMStopper* aStopper ) |
114 { |
150 { |
|
151 MEM_LOGF(_L8("MemoryManager::AddStopper - s_pool=%x"), s_pool); |
115 Pool()->AddStopper( aStopper ); |
152 Pool()->AddStopper( aStopper ); |
116 } |
153 } |
117 |
154 |
118 //----------------------------------------------------------------------------- |
155 //----------------------------------------------------------------------------- |
119 // MemoryManager::RemoveStopper |
156 // MemoryManager::RemoveStopper |