// Does the EGL extension return the amount of memory in bits? // If yes, int is clearly not enough // Note that this function reserves memory so it can fail if the "standard" memory // gets full. TBool CMemoryMonitor::FreeGraphicsMemoryAboveThresholdL(TInt& aCurrentFreeMemory) { FUNC_LOG; TInt current = GetFreeMemory(); User::LeaveIfError(current); aCurrentFreeMemory = current; return (current >= iCurrentTarget); }
TBool CMemoryMonitor::SwitchRenderingToHW() { FUNC_LOG; TInt current = GetFreeMemory(); if(current >= iGoodThreshold) { SwitchMemMode(EGOomGoodMemMode, ETrue); iMemAllocationsGrowing->Continue(); return ETrue; } return EFalse; }
// --------------------------------------------------------- // // --------------------------------------------------------- // void CMemoryMonitor::FreeMemThresholdCrossedL(TInt /*aAction*/, TInt aThreshold) { FUNC_LOG; // keep only one notification active at a moment #ifdef USE_ASYNCYH_NOTIFICATIONS if (aThreshold == EGL_PROF_TOTAL_MEMORY_USAGE_LT_NOK) { TInt current = GetFreeMemory(); if(current >= iGoodThreshold && (!NeedToPostponeMemGood())) { TRACES2("FreeMemThresholdCrossedL : crossed good threshold Free %d, GThresh %d, Calling MemoryGood",current, iGoodThreshold); iGOomActionList->MemoryGood(); iMemAllocationsGrowing->Continue(); iMemAllocationsGoingDown->Stop(); return; } else { TRACES3("FreeMemThresholdCrossedL : Not Calling MemoryGOOD. Free %d, GThresh %d, Handshakepending = %d",current, iGoodThreshold, NeedToPostponeMemGood()?1:0); //if we remain in low mem mode, we have to wait for the same trigger i.e. free mem crossing good threshold if(NeedToPostponeMemGood()) //if handshake pending iMemAllocationsGoingDown->Stop(); //Stop till handhsake is complete. It will be made to continue from DoPostponedMemoryGood else iMemAllocationsGoingDown->Continue(); } } else//if aThreshold == EGL_PROF_TOTAL_MEMORY_USAGE_GT_NOK { TRACES1("FreeMemThresholdCrossedL : crossed low threshold %d", iLowThreshold); iMemAllocationsGrowing->Stop(); iMemAllocationsGoingDown->Continue(); if((iTrigger == EGOomTriggerNone) && !NeedToPostponeMemGood()) { if(iSynchTimer->IsActive()) iSynchTimer->Cancel(); StartFreeSomeRamL(iGoodThreshold, EGOomTriggerThresholdCrossed); } } #endif }
void CMemoryMonitor::SynchroniseMemoryState() { FUNC_LOG; TInt current = GetFreeMemory(); if(current >= iGoodThreshold) { iClientsRequestingMemory.Reset(); TRACES("SynchroniseMemoryState calling MemoryGOOD"); iGOomActionList->MemoryGood(); } else if(current < iLowThreshold) { iMemAllocationsGrowing->Stop(); iMemAllocationsGoingDown->Continue(); } else { iMemAllocationsGrowing->Continue(); iMemAllocationsGoingDown->Continue(); } }
TBool CMemoryMonitor::DoPostponedMemoryGood() { FUNC_LOG; TInt current = GetFreeMemory(); if(current >= iGoodThreshold) { if(!NeedToPostponeMemGood()) { TRACES2("DoPostponedMemoryGood calling MemoryGOOD current %d, iGoodThreshold %d",current, iGoodThreshold); iGOomActionList->MemoryGood(); return ETrue; } else { iMemAllocationsGoingDown->Continue(); } } else { iMemAllocationsGoingDown->Continue(); } return EFalse; }
void BaseApp::Draw() { #ifdef _DEBUG //LogMsg("**********FRAME START"); #endif VariantList vList(Variant(0,0)); m_sig_render(&vList); if (GetFPSVisible()) { char stTemp[256]; sprintf(stTemp, "fps: %d - M: %.2f, T: %.2f A: %.2f F: %.2f", m_gameTimer.GetFPS(), (float(m_memUsed)/1024)/1024, (float(m_texMemUsed)/1024)/1024, float(GetAudioManager()->GetMemoryUsed()/1024)/ 1024, float(GetFreeMemory()/1024)/ 1024); #ifdef _IRR_STATIC_LIB_ int prims = 0; if (GetIrrlichtManager()->GetDriver()) { prims = GetIrrlichtManager()->GetDriver()->getPrimitiveCountDrawn(); } char stExtra[256]; sprintf(stExtra, " Prims: %d", prims); strcat(stTemp, stExtra); #endif #ifdef PLATFORM_FLASH char stExtra[256]; sprintf(stExtra, " Flash: %.2f", float(GetNativeMemoryUsed())/1024/1024); strcat(stTemp, stExtra); #endif if (GetFont(FONT_SMALL)->IsLoaded()) { GetFont(FONT_SMALL)->DrawScaled(3,3, stTemp, 0.7f); } } //draw the console messages? if (GetConsoleVisible()) { DrawConsole(); } switch (GetLastError()) { case ERROR_MEM: GetFont(FONT_SMALL)->DrawScaled(2,14, "LOW MEM!", 0.7f); break; case ERROR_SPACE: GetFont(FONT_SMALL)->DrawScaled(2,14, "LOW STORAGE SPACE!", 0.7f); break; case ERROR_NONE: break; } SetupOrtho(); g_globalBatcher.Flush(); }
void CMemoryMonitor::RefreshThresholds(TInt aForegroundAppUid) { FUNC_LOG; TInt origGood = iGoodThreshold; TInt origLow = iLowThreshold; // Calculate the desired good threshold, this could be the globally configured value... iGoodThreshold = CMemoryMonitor::GlobalConfig().iGoodRamThreshold; iLowThreshold = CMemoryMonitor::GlobalConfig().iLowRamThreshold; //if(iCurrentTarget < iLowThreshold) // iCurrentTarget = iLowThreshold; TRACES2("CMemoryMonitor::RefreshThresholds: Global Good Threshold = %d, Global Low Threshold = %d", iGoodThreshold, iLowThreshold); TBool useSwRendering = EFalse; // The global value can be overridden by an app specific value // Find the application config entry for the foreground application if (aForegroundAppUid == KErrNotFound) { return; } // If this application configuration overrides the good_ram_threshold then set it if (iConfig->GetApplicationConfig(aForegroundAppUid).iGoodRamThreshold != KGOomThresholdUnset) { iGoodThreshold = iConfig->GetApplicationConfig(aForegroundAppUid).iGoodRamThreshold; TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Good Threshold = %d", aForegroundAppUid, iGoodThreshold); } // If this application configuration overrides the low_ram_threshold then set it if (iConfig->GetApplicationConfig(aForegroundAppUid).iLowRamThreshold != KGOomThresholdUnset) { iLowThreshold = iConfig->GetApplicationConfig(aForegroundAppUid).iLowRamThreshold; TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Low Threshold = %d", aForegroundAppUid, iLowThreshold); } // If this application configuration overrides the good_ram_threshold then set it if (iConfig->GetApplicationConfig(aForegroundAppUid).iTargetFree != KGOomThresholdUnset) { iCurrentTarget = iConfig->GetApplicationConfig(aForegroundAppUid).iTargetFree; TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Target Free on Startup = %d", aForegroundAppUid, iCurrentTarget); } if (iConfig->GetApplicationConfig(aForegroundAppUid).iUseSwRendering != KGOomThresholdUnset) { useSwRendering = iConfig->GetApplicationConfig(aForegroundAppUid).iUseSwRendering; TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, UseSwRendering = %d", aForegroundAppUid, useSwRendering); } iGOomActionList->SetCurrentTarget(iCurrentTarget); iGOomActionList->SetUseSwRendering(useSwRendering); #ifdef USE_ASYNCYH_NOTIFICATIONS // if allocation should fail, threshold should not naturally be set if (!iMemAllocationsGrowing) { TRAP_IGNORE(iMemAllocationsGrowing = CreateThresholdCrossedThreadL(*this, EGL_PROF_TOTAL_MEMORY_USAGE_GT_NOK, iLowThreshold)) origLow = iLowThreshold; // do not reset } if (!iMemAllocationsGoingDown) { TRAP_IGNORE(iMemAllocationsGoingDown = CreateThresholdCrossedThreadL(*this, EGL_PROF_TOTAL_MEMORY_USAGE_LT_NOK, iGoodThreshold)) origGood = iGoodThreshold; // do not reset } TBool releaseClient = ETrue; // update thresholds only if they really change if (origGood != iGoodThreshold) { iMemAllocationsGoingDown->SetThreshold(iGoodThreshold); } if ( origLow != iLowThreshold) { // need to synchronously check whether client should wait // memory to be released if(GetFreeMemory() <= iLowThreshold ) { releaseClient = EFalse; } iMemAllocationsGrowing->SetThreshold(iLowThreshold); } TRACES3("CMemoryMonitor::RefreshThresholds: releaseClient: %d For foreground app 0x%x, Active client = 0x%x",releaseClient, aForegroundAppUid, ActiveClientId()); if (releaseClient && ActiveClientId() == iForegroundAppUid) { iServer->CloseAppsFinished(0, ETrue); } #endif TRACES2("CMemoryMonitor::RefreshThresholds: Current Good Threshold = %d, Current Low Threshold = %d", iGoodThreshold, iLowThreshold); }