130 //----------------------------------------------------------------------------- |
131 //----------------------------------------------------------------------------- |
131 // CMemoryPool::CollectMemory |
132 // CMemoryPool::CollectMemory |
132 //----------------------------------------------------------------------------- |
133 //----------------------------------------------------------------------------- |
133 void CMemoryPool::CollectMemory(TUint aSize) |
134 void CMemoryPool::CollectMemory(TUint aSize) |
134 { |
135 { |
|
136 MEM_LOG("CMemoryPool::CollectMemory - run"); |
135 if( iIsCollecting ) return; |
137 if( iIsCollecting ) return; |
136 |
138 |
137 iIsCollecting = ETrue; |
139 iIsCollecting = ETrue; |
138 for( TInt i=0; i<iCollectors.Count(); ++i ) |
140 for( TInt i=0; i<iCollectors.Count(); ++i ) |
139 { |
141 { |
140 iCollectors[i]->Collect(aSize); |
142 iCollectors[i]->Collect(aSize); |
141 } |
143 } |
142 |
|
143 User::CompressAllHeaps(); |
|
144 iIsCollecting = EFalse; |
144 iIsCollecting = EFalse; |
145 |
145 |
146 if (iStopScheduler) |
146 if (iStopScheduler && !iIsStopping ) |
147 iStopScheduler->Start( CStopScheduler::ECheckMemory, aSize ); |
147 iStopScheduler->Start( CStopScheduler::ECheckMemory, aSize ); |
148 } |
148 } |
149 |
149 |
150 //----------------------------------------------------------------------------- |
150 //----------------------------------------------------------------------------- |
151 // CMemoryPool::RestoreCollectors |
151 // CMemoryPool::RestoreCollectors |
465 |
465 |
466 #ifdef __NEW_ALLOCATOR__ |
466 #ifdef __NEW_ALLOCATOR__ |
467 //----------------------------------------------------------------------------- |
467 //----------------------------------------------------------------------------- |
468 // CNewSymbianHeapPool::FreeMemory |
468 // CNewSymbianHeapPool::FreeMemory |
469 //----------------------------------------------------------------------------- |
469 //----------------------------------------------------------------------------- |
470 TUint CNewSymbianHeapPool::FreeMemory(TFreeMem& /*aFree*/ ) |
470 TUint CNewSymbianHeapPool::FreeMemory(TFreeMem& aFree ) |
471 { |
471 { |
472 // TODO: implement free_memory |
472 // TODO: implement free_memory |
473 return KMaxTUint; |
473 aFree.iPool = 0; |
474 // return free_memory( aFree.iPool, aFree.iHeap, aFree.iHal ); |
474 aFree.iHeap = 0; |
|
475 |
|
476 TInt freeRAM; |
|
477 if(HAL::Get(HALData::EMemoryRAMFree, freeRAM) == KErrNone) |
|
478 aFree.iHal = freeRAM; |
|
479 else |
|
480 aFree.iHal = 0; |
|
481 |
|
482 return KMaxTUint; // not fully implemented |
475 } |
483 } |
476 |
484 |
477 //----------------------------------------------------------------------------- |
485 //----------------------------------------------------------------------------- |
478 // CNewSymbianHeapPool::DoAlloc |
486 // CNewSymbianHeapPool::DoAlloc |
479 //----------------------------------------------------------------------------- |
487 //----------------------------------------------------------------------------- |
480 TAny* CNewSymbianHeapPool::DoAlloc( TUint aSize ) |
488 TAny* CNewSymbianHeapPool::DoAlloc( TUint aSize ) |
481 { |
489 { |
482 TAny *p = iAlloc->Alloc( aSize ); |
490 TAny *p = iAlloc->Alloc( aSize ); |
483 if (!p) |
491 if(iAlloc->isLowSystemMemory && p) // use this a pre OOM indicator |
|
492 { |
|
493 iStopScheduler->Start( CStopScheduler::ECheckMemory, 0 ); |
|
494 iAlloc->isLowSystemMemory = 0; // reset so that we don't check before next request for RAM |
|
495 } |
|
496 |
|
497 if (!p) { |
484 ShowOOMDialog(); |
498 ShowOOMDialog(); |
|
499 MEM_LOG("CNewSymbianHeapPool::DoAlloc - failed"); |
|
500 } |
485 return p; |
501 return p; |
486 } |
502 } |
487 |
503 |
488 //----------------------------------------------------------------------------- |
504 //----------------------------------------------------------------------------- |
489 // CNewSymbianHeapPool::ReAllocate |
505 // CNewSymbianHeapPool::ReAllocate |
492 { |
508 { |
493 // reset the status for next allocation |
509 // reset the status for next allocation |
494 iMemStatus &= ~ERescueOOM; |
510 iMemStatus &= ~ERescueOOM; |
495 |
511 |
496 TAny* p = iAlloc->ReAlloc( aPtr, aSize ); |
512 TAny* p = iAlloc->ReAlloc( aPtr, aSize ); |
497 |
513 if(iAlloc->isLowSystemMemory && p) // use this a pre OOM indicator |
|
514 { |
|
515 iStopScheduler->Start( CStopScheduler::ECheckMemory, 0 ); |
|
516 iAlloc->isLowSystemMemory = 0; // reset so that we don't check before next request for RAM |
|
517 } |
|
518 |
498 // check memory manager status |
519 // check memory manager status |
499 if( !p || iMemStatus & ERescueOOM ) |
520 if( !p || iMemStatus & ERescueOOM ) |
500 { |
521 { |
501 ShowOOMDialog(); |
522 ShowOOMDialog(); |
502 if( !iIsCollecting ) |
523 if( !iIsCollecting ) |