uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp
changeset 19 f5bac0badc7e
parent 14 83d2d132aa58
child 25 f7f1ae431f74
equal deleted inserted replaced
14:83d2d132aa58 19:f5bac0badc7e
   229     else//if aThreshold == EGL_PROF_TOTAL_MEMORY_USAGE_GT_NOK
   229     else//if aThreshold == EGL_PROF_TOTAL_MEMORY_USAGE_GT_NOK
   230         {
   230         {
   231         TRACES1("FreeMemThresholdCrossedL : crossed low threshold %d", iLowThreshold);
   231         TRACES1("FreeMemThresholdCrossedL : crossed low threshold %d", iLowThreshold);
   232         iMemAllocationsGrowing->Stop();
   232         iMemAllocationsGrowing->Stop();
   233         iMemAllocationsGoingDown->Continue();
   233         iMemAllocationsGoingDown->Continue();
   234         if(iTrigger == EGOomTriggerNone)
   234         if((iTrigger == EGOomTriggerNone) && !NeedToPostponeMemGood() && !iSynchTimer->IsActive() )
   235             StartFreeSomeRamL(iGoodThreshold, EGOomTriggerThresholdCrossed);
   235             StartFreeSomeRamL(iGoodThreshold, EGOomTriggerThresholdCrossed);
   236         }
   236         }
   237 #endif
   237 #endif
   238     }
   238     }
   239 
   239 
   249         }
   249         }
   250     iForegroundAppUid = aForegroundAppUid;    
   250     iForegroundAppUid = aForegroundAppUid;    
   251 
   251 
   252     // Refresh the low and good memory thresholds as they may have changed due to the new foreground application
   252     // Refresh the low and good memory thresholds as they may have changed due to the new foreground application
   253     RefreshThresholds(aForegroundAppUid);
   253     RefreshThresholds(aForegroundAppUid);
   254     // Not very elegant, now we poll on each window group change
   254     
   255     // Should have better trigger e.g. from window server 
   255     if(iCurrentTarget)
   256 	StartFreeSomeRamL(iCurrentTarget, EGOomTriggerFocusChanged);
   256         {
       
   257         StartFreeSomeRamL(iCurrentTarget, EGOomTriggerFocusChanged);
       
   258         }
   257      }
   259      }
   258 
   260 
   259 void CMemoryMonitor::StartFreeSomeRamL(TInt aTargetFree, TInt aMaxPriority, TGOomTrigger aTrigger) // The maximum priority of action to run
   261 void CMemoryMonitor::StartFreeSomeRamL(TInt aTargetFree, TInt aMaxPriority, TGOomTrigger aTrigger) // The maximum priority of action to run
   260     {
   262     {
   261     FUNC_LOG;
   263     FUNC_LOG;
   273 
   275 
   274     TRACES2("MemoryMonitor::StartFreeSomeRamL freeMemoryAboveTarget = %d, freeMemory = %d", freeMemoryAboveCurrentTarget, freeMemory);
   276     TRACES2("MemoryMonitor::StartFreeSomeRamL freeMemoryAboveTarget = %d, freeMemory = %d", freeMemoryAboveCurrentTarget, freeMemory);
   275 
   277 
   276     if (freeMemoryAboveCurrentTarget)
   278     if (freeMemoryAboveCurrentTarget)
   277         {
   279         {
   278         ResetTargets();
       
   279         /*if(freeMemory >= iGoodThreshold && !NeedToPostponeMemGood())
   280         /*if(freeMemory >= iGoodThreshold && !NeedToPostponeMemGood())
   280             {
   281             {
   281                 iGOomActionList->MemoryGood();
   282                 iGOomActionList->MemoryGood();
   282             }
   283             }
   283         */
   284         */
   284         iServer->CloseAppsFinished(freeMemory, ETrue);
   285         if(!iGOomActionList->UseSwRendering())
   285         return;
   286             {
       
   287             iServer->CloseAppsFinished(freeMemory, ETrue);
       
   288             WaitAndSynchroniseMemoryState();
       
   289             return;
       
   290             }
   286         }
   291         }
   287 
   292 
   288     // update wg list only when actually about to use it 
   293     // update wg list only when actually about to use it 
   289     //iGOomWindowGroupList->Refresh();
   294     //iGOomWindowGroupList->Refresh();
   290 
   295 
   377     TInt origLow = iLowThreshold;
   382     TInt origLow = iLowThreshold;
   378     
   383     
   379     // Calculate the desired good threshold, this could be the globally configured value...
   384     // Calculate the desired good threshold, this could be the globally configured value...
   380     iGoodThreshold = CMemoryMonitor::GlobalConfig().iGoodRamThreshold;
   385     iGoodThreshold = CMemoryMonitor::GlobalConfig().iGoodRamThreshold;
   381     iLowThreshold = CMemoryMonitor::GlobalConfig().iLowRamThreshold;
   386     iLowThreshold = CMemoryMonitor::GlobalConfig().iLowRamThreshold;
   382     if(iCurrentTarget < iLowThreshold)
   387     //if(iCurrentTarget < iLowThreshold)
   383         iCurrentTarget = iLowThreshold;
   388     //    iCurrentTarget = iLowThreshold;
   384         
   389         
   385     TRACES2("CMemoryMonitor::RefreshThresholds: Global Good Threshold = %d, Global Low Threshold = %d", iGoodThreshold, iLowThreshold);
   390     TRACES2("CMemoryMonitor::RefreshThresholds: Global Good Threshold = %d, Global Low Threshold = %d", iGoodThreshold, iLowThreshold);
   386 
   391 
       
   392     TBool useSwRendering = EFalse;
   387     // The global value can be overridden by an app specific value
   393     // The global value can be overridden by an app specific value
   388     // Find the application config entry for the foreground application
   394     // Find the application config entry for the foreground application
   389     if (aForegroundAppUid == KErrNotFound)
   395     if (aForegroundAppUid == KErrNotFound)
   390         {
   396         {
   391         return;
   397         return;
   410         {
   416         {
   411         iCurrentTarget = iConfig->GetApplicationConfig(aForegroundAppUid).iTargetFree;
   417         iCurrentTarget = iConfig->GetApplicationConfig(aForegroundAppUid).iTargetFree;
   412         TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Target Free on Startup = %d", aForegroundAppUid, iCurrentTarget);
   418         TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Target Free on Startup = %d", aForegroundAppUid, iCurrentTarget);
   413         }
   419         }
   414     
   420     
       
   421 
       
   422     if (iConfig->GetApplicationConfig(aForegroundAppUid).iUseSwRendering != KGOomThresholdUnset)
       
   423         {
       
   424         useSwRendering = iConfig->GetApplicationConfig(aForegroundAppUid).iUseSwRendering;
       
   425         TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, UseSwRendering = %d", aForegroundAppUid, useSwRendering);
       
   426         }
       
   427     
   415     iGOomActionList->SetCurrentTarget(iCurrentTarget);
   428     iGOomActionList->SetCurrentTarget(iCurrentTarget);
       
   429     iGOomActionList->SetUseSwRendering(useSwRendering);
   416     
   430     
   417 #ifdef USE_ASYNCYH_NOTIFICATIONS 
   431 #ifdef USE_ASYNCYH_NOTIFICATIONS 
   418 
   432 
   419     // if allocation should fail, threshold should not naturally be set
   433     // if allocation should fail, threshold should not naturally be set
   420     if (!iMemAllocationsGrowing)
   434     if (!iMemAllocationsGrowing)
   465     //we reset the target when a memory free operation completes, to deal with the case
   479     //we reset the target when a memory free operation completes, to deal with the case
   466     //where the operation was initiated with a target larger than the current good threshold
   480     //where the operation was initiated with a target larger than the current good threshold
   467     iCurrentTarget = aTarget;
   481     iCurrentTarget = aTarget;
   468     iGOomActionList->SetCurrentTarget(iCurrentTarget);
   482     iGOomActionList->SetCurrentTarget(iCurrentTarget);
   469     if(!aTarget)
   483     if(!aTarget)
       
   484         {
   470         iTrigger = EGOomTriggerNone;    //reset the trigger condition
   485         iTrigger = EGOomTriggerNone;    //reset the trigger condition
       
   486         }
       
   487     iGOomActionList->SetUseSwRendering(EFalse);
   471     }
   488     }
   472 
   489 
   473 void CMemoryMonitor::SetPriorityBusy(TInt aWgId)
   490 void CMemoryMonitor::SetPriorityBusy(TInt aWgId)
   474     {
   491     {
   475     FUNC_LOG;
   492     FUNC_LOG;
   590                     i++;
   607                     i++;
   591                     }
   608                     }
   592                 break;
   609                 break;
   593                 }
   610                 }
   594             case EGL_PROF_PROCESS_USED_PRIVATE_MEMORY_NOK:
   611             case EGL_PROF_PROCESS_USED_PRIVATE_MEMORY_NOK:
       
   612                     {
       
   613                     TUint mem = prof_data[i];
       
   614                     TRACES1("Private memory Usage by app is %d", mem);
       
   615                     break;
       
   616                     }
   595             case EGL_PROF_PROCESS_USED_SHARED_MEMORY_NOK:
   617             case EGL_PROF_PROCESS_USED_SHARED_MEMORY_NOK:
       
   618                     {
       
   619                     TUint mem = prof_data[i];
       
   620                     TRACES1("Shared memory Usage by app is %d", mem);
       
   621                     break;
       
   622                     }
   596 			default:
   623 			default:
   597 				{
   624 				{
   598                 i++;
   625                 i++;
   599 				break;
   626 				break;
   600 				}
   627 				}