uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp
branchRCL_3
changeset 20 31fccae4f8a7
parent 19 e5af45d51884
child 21 78e19bc09b73
equal deleted inserted replaced
19:e5af45d51884 20:31fccae4f8a7
   203 void CMemoryMonitor::FreeMemThresholdCrossedL(TInt /*aAction*/, TInt aThreshold)
   203 void CMemoryMonitor::FreeMemThresholdCrossedL(TInt /*aAction*/, TInt aThreshold)
   204     {
   204     {
   205     FUNC_LOG;
   205     FUNC_LOG;
   206     // keep only one notification active at a moment
   206     // keep only one notification active at a moment
   207 #ifdef USE_ASYNCYH_NOTIFICATIONS 
   207 #ifdef USE_ASYNCYH_NOTIFICATIONS 
   208    
   208     TInt current = GetFreeMemory();
   209     if (aThreshold == EGL_PROF_TOTAL_MEMORY_USAGE_LT_NOK)
   209     if (aThreshold == EGL_PROF_TOTAL_MEMORY_USAGE_LT_NOK)
   210         {
   210         {
   211         TInt current = GetFreeMemory();
       
   212         if(current >= iGoodThreshold  && (!NeedToPostponeMemGood()))
   211         if(current >= iGoodThreshold  && (!NeedToPostponeMemGood()))
   213             {
   212             {
   214             TRACES2("FreeMemThresholdCrossedL : crossed good threshold Free %d, GThresh %d, Calling MemoryGood",current, iGoodThreshold);
   213             TRACES2("FreeMemThresholdCrossedL : crossed good threshold Free %d, GThresh %d, Calling MemoryGood",current, iGoodThreshold);
   215             iGOomActionList->MemoryGood();
   214             iGOomActionList->MemoryGood();
   216             iMemAllocationsGrowing->Continue();
   215             iMemAllocationsGrowing->Continue();
   228                 iMemAllocationsGoingDown->Continue();
   227                 iMemAllocationsGoingDown->Continue();
   229             }
   228             }
   230         }
   229         }
   231     else//if aThreshold == EGL_PROF_TOTAL_MEMORY_USAGE_GT_NOK
   230     else//if aThreshold == EGL_PROF_TOTAL_MEMORY_USAGE_GT_NOK
   232         {
   231         {
   233         TRACES1("FreeMemThresholdCrossedL : crossed low threshold %d", iLowThreshold);
   232         if(current < iLowThreshold)
   234         iMemAllocationsGrowing->Stop();
   233             {
   235         iMemAllocationsGoingDown->Continue();
   234             TRACES1("FreeMemThresholdCrossedL : crossed low threshold %d", iLowThreshold);
   236         if((iTrigger == EGOomTriggerNone) && !NeedToPostponeMemGood())
   235             iMemAllocationsGrowing->Stop();
   237             {
   236             iMemAllocationsGoingDown->Continue();
   238             if(iSynchTimer->IsActive())
   237             if((iTrigger == EGOomTriggerNone) && !NeedToPostponeMemGood())
   239                 iSynchTimer->Cancel();
   238                 {
   240             StartFreeSomeRamL(iGoodThreshold, EGOomTriggerThresholdCrossed);
   239                 if(iSynchTimer->IsActive())
   241             }
   240                     iSynchTimer->Cancel();
       
   241                 StartFreeSomeRamL(iGoodThreshold, EGOomTriggerThresholdCrossed);
       
   242                 }
       
   243             }
       
   244         else
       
   245             TRACES2("FreeMemThresholdCrossedL : crossed low threshold %d, FALSE ALARM, FreeMem = %d", iLowThreshold, current);
   242         }
   246         }
   243 #endif
   247 #endif
   244     }
   248     }
   245 
   249 
   246 void CMemoryMonitor::HandleFocusedWgChangeL(TInt aForegroundAppUid)
   250 void CMemoryMonitor::HandleFocusedWgChangeL(TInt aForegroundAppUid)
   333     
   337     
   334     iGOomActionList->SetUseSwRendering(ETrue); //Always use SW rendering in low mode .. (for now..) 
   338     iGOomActionList->SetUseSwRendering(ETrue); //Always use SW rendering in low mode .. (for now..) 
   335     // Run the memory freeing actions
   339     // Run the memory freeing actions
   336     iGOomActionList->FreeMemory(aMaxPriority);
   340     iGOomActionList->FreeMemory(aMaxPriority);
   337     
   341     
       
   342     SwitchMemMode(EGOomLowMemMode);
   338     }
   343     }
   339 
   344 
   340 void CMemoryMonitor::SwitchMemMode(TGOomMemMode aMemMode)
   345 void CMemoryMonitor::SwitchMemMode(TGOomMemMode aMemMode)
   341     {
   346     {
   342     if(iMemMode == aMemMode)
   347     if(iMemMode == aMemMode)
   343         {
       
   344         if(iMemMode == EGOomGoodMemMode)
       
   345             {
       
   346             TRACES("CMemoryMonitor::SwitchMemMode NOT switching rendering mode. Already in GOOD Mode");
       
   347             }
       
   348         else
       
   349             {
       
   350             TRACES("CMemoryMonitor::SwitchMemMode NOT switching rendering mode. Already in LOW Mode");
       
   351             }
       
   352         return;
   348         return;
   353         }
       
   354 
   349 
   355 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS    
   350 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS    
   356     TWsEvent event;
   351     TWsEvent event;
   357  
   352  
   358     if(aMemMode == EGOomLowMemMode)
   353     if(aMemMode == EGOomLowMemMode)
   363             return;
   358             return;
   364         
   359         
   365         iLowOnMemWgs.Reset();
   360         iLowOnMemWgs.Reset();
   366         iGOomWindowGroupList->GetListOfWindowGroupsWSurfaces(iLowOnMemWgs);
   361         iGOomWindowGroupList->GetListOfWindowGroupsWSurfaces(iLowOnMemWgs);
   367         event.SetType(KGoomMemoryLowEvent);
   362         event.SetType(KGoomMemoryLowEvent);
   368         TRACES("CMemoryMonitor::SwitchMemMode. Switching rendering mode to SW, Sending KGoomMemoryLowEvent");
       
   369         }
   363         }
   370     else
   364     else
   371         {
   365         {
   372         if(iRendswitched > 0)
   366         if(iRendswitched > 0)
   373             {
   367             {
   374             if(iRendswitched < 3)
   368             if(iRendswitched < 3)
   375                 iRendswitched ++;
   369                 iRendswitched ++;
   376             else
   370             else
   377                 {
       
   378                 TRACES("CMemoryMonitor::SwitchMemMode GOOM Detected SW-HW-SW looping. NOT switching to HW rendering mode");
       
   379                 return;
   371                 return;
   380                 }
       
   381             }
   372             }
   382     
   373     
   383         event.SetType(KGoomMemoryGoodEvent);
   374         event.SetType(KGoomMemoryGoodEvent);
   384         TRACES("CMemoryMonitor::SwitchMemMode. Switching rendering mode to HW, Sending KGoomMemoryGoodEvent");
       
   385         }
   375         }
   386     
   376     
   387     for (TInt i = iLowOnMemWgs.Count()-1; i>=0; i--)
   377     for (TInt i = iLowOnMemWgs.Count()-1; i>=0; i--)
   388         {
   378         {
   389         iWs.SendEventToWindowGroup(iLowOnMemWgs[i], event);
   379         iWs.SendEventToWindowGroup(iLowOnMemWgs[i], event);
   390         TRACES1("CMemoryMonitor::SwitchMemMode. Sending event to wg %d",iLowOnMemWgs[i]);
       
   391         }
   380         }
   392 #endif
   381 #endif
   393     
   382     
   394     iMemMode = aMemMode;
   383     iMemMode = aMemMode;
   395     }
   384     }