--- a/sysresmonitoring/oommonitor/src/oommemorymonitor.cpp Wed Sep 15 12:23:15 2010 +0300
+++ b/sysresmonitoring/oommonitor/src/oommemorymonitor.cpp Wed Oct 13 14:43:04 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
@@ -18,7 +18,6 @@
#include <hal.h>
-
#include <UikonInternalPSKeys.h>
#include "oommemorymonitor.h"
@@ -163,7 +162,7 @@
#endif
- iOOMWatcher = COutOfMemoryWatcher::NewL(*this, iLowRamThreshold, iGoodRamThreshold, iConfig->GlobalConfig().iSwapUsageMonitored, iLowSwapThreshold, iGoodSwapThreshold);
+ iOOMWatcher = COutOfMemoryWatcher::NewL(*this, iLowThreshold, iGoodThreshold);
iOOMWatcher->Start();
iWservEventReceiver = new(ELeave) CWservEventReceiver(*this, iWs);
@@ -186,86 +185,61 @@
FUNC_LOG;
iActionTrigger = ERamRotation;
- StartFreeSomeRamL(iGoodRamThreshold, iGoodSwapThreshold);
+ StartFreeSomeRamL(iGoodThreshold);
}
void CMemoryMonitor::HandleFocusedWgChangeL()
{
FUNC_LOG;
- TInt oldGoodRamThreshold = iGoodRamThreshold;
- TInt oldLowRamThreshold = iLowRamThreshold;
- TInt oldGoodSwapThreshold = iGoodSwapThreshold;
- TInt oldLowSwapThreshold = iLowSwapThreshold;
-
+ TInt oldGoodThreshold = iGoodThreshold;
+ TInt oldLowThreshold = iLowThreshold;
+
// Refresh the low and good memory thresholds as they may have changed due to the new foreground application
RefreshThresholds();
- if ((oldGoodRamThreshold != iGoodRamThreshold)
- || (oldLowRamThreshold != iLowRamThreshold)
- || (oldGoodSwapThreshold != iGoodSwapThreshold)
- || (oldLowSwapThreshold != iLowSwapThreshold))
+ if ((oldGoodThreshold != iGoodThreshold)
+ || (oldLowThreshold != iLowThreshold))
// If the thresholds have changed then update the memory watched
{
- iOOMWatcher->UpdateThresholds(iLowRamThreshold, iGoodRamThreshold, iLowSwapThreshold, iGoodSwapThreshold);
+ iOOMWatcher->UpdateThresholds(iLowThreshold, iGoodThreshold);
}
// If the available memory is less than the low memory threshold then free some RAM
User::CompressAllHeaps();
- TInt currentFreeRam = 0;
- HAL::Get( HALData::EMemoryRAMFree, currentFreeRam );
- TInt currentFreeSwap = 0;
- if (iConfig->GlobalConfig().iSwapUsageMonitored)
- {
- SVMSwapInfo swapInfo;
- UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo, 0);
- currentFreeSwap = swapInfo.iSwapFree;
- }
+ TInt current = 0;
+ HAL::Get( HALData::EMemoryRAMFree, current );
- if ((currentFreeRam < iLowRamThreshold) ||
- (iConfig->GlobalConfig().iSwapUsageMonitored && (currentFreeSwap < iLowSwapThreshold)))
+ if (current < iLowThreshold)
{
iActionTrigger = ERamRotation;
- StartFreeSomeRamL(iGoodRamThreshold, iGoodSwapThreshold);
+ StartFreeSomeRamL(iGoodThreshold);
}
}
-void CMemoryMonitor::StartFreeSomeRamL(TInt aFreeRamTarget, TInt aFreeSwapTarget)
+void CMemoryMonitor::StartFreeSomeRamL(TInt aTargetFree)
{
- StartFreeSomeRamL(aFreeRamTarget, aFreeSwapTarget, KOomPriorityInfinate - 1);
+ StartFreeSomeRamL(aTargetFree, KOomPriorityInfinate - 1);
}
-void CMemoryMonitor::StartFreeSomeRamL(TInt aFreeRamTarget, TInt aFreeSwapTarget, TInt aMaxPriority) // The maximum priority of action to run
+void CMemoryMonitor::StartFreeSomeRamL(TInt aTargetFree, TInt aMaxPriority) // The maximum priority of action to run
{
FUNC_LOG;
- TRACES4("MemoryMonitor::StartFreeSomeRamL: aFreeRamTarget = %d, iCurrentRamTarget = %d, aFreeSwapSpaceTarget = %d, iCurrentSwapTarget = %d", aFreeRamTarget, iCurrentRamTarget, aFreeSwapTarget, iCurrentSwapTarget);
+ TRACES2("MemoryMonitor::StartFreeSomeRamL: aTargetFree = %d, iCurrentTarget = %d", aTargetFree, iCurrentTarget);
// Update the target if new target is higher. If the target is lower than the current target and memory
// is currently being freed then we do not want to reduce the amount of memory this operation frees.
- if (aFreeRamTarget > iCurrentRamTarget)
- {
- iCurrentRamTarget = aFreeRamTarget;
- }
-
- if (aFreeSwapTarget > iCurrentSwapTarget)
- {
- iCurrentSwapTarget = aFreeSwapTarget;
- }
+ if (aTargetFree > iCurrentTarget)
+ iCurrentTarget = aTargetFree;
// check if there is enough free memory already.
- TInt freeMemory = 0;
+ TInt freeMemory;
GetFreeMemory(freeMemory);
- TInt freeSwap = 0;
- if (iConfig->GlobalConfig().iSwapUsageMonitored)
- {
- GetFreeSwapSpace(freeSwap);
- }
- TRACES2("MemoryMonitor::StartFreeSomeRamL, freeMemory = %d, freeSwap = %d", freeMemory, freeSwap);
+ TRACES1("MemoryMonitor::StartFreeSomeRamL, freeMemory = %d", freeMemory);
- if ((freeMemory >= iCurrentRamTarget) &&
- ((!iConfig->GlobalConfig().iSwapUsageMonitored) || (freeSwap >= iCurrentSwapTarget)))
+ if (freeMemory >= iCurrentTarget)
{
if (iLastMemoryMonitorStatusProperty != EFreeingMemory)
{
@@ -288,7 +262,7 @@
// Build the list of memory freeing actions
iOomActionList->BuildActionListL(*iOomWindowGroupList, *iConfig);
- iOomActionList->SetCurrentTargets(iCurrentRamTarget, iCurrentSwapTarget);
+ iOomActionList->SetCurrentTarget(iCurrentTarget);
// Run the memory freeing actions
iOomActionList->FreeMemory(aMaxPriority);
@@ -299,30 +273,27 @@
FUNC_LOG;
iActionTrigger = EPublishAndSubscribe;
- StartFreeSomeRamL(aBytesRequested + iLowRamThreshold, iLowSwapThreshold);
+ StartFreeSomeRamL(aBytesRequested + iLowThreshold);
}
-void CMemoryMonitor::RequestFreeMemoryL(TInt aBytesRequested, TBool aDataPaged)
+void CMemoryMonitor::RequestFreeMemoryL(TInt aBytesRequested)
{
FUNC_LOG;
iActionTrigger = EClientServerRequestFreeMemory;
- iDataPaged = aDataPaged;
- StartFreeSomeRamL(iLowRamThreshold, aBytesRequested + iLowSwapThreshold);
+ StartFreeSomeRamL(aBytesRequested + iLowThreshold);
}
-void CMemoryMonitor::FreeOptionalRamL(TInt aBytesRequested, TInt aPluginId, TBool aDataPaged) // The ID of the plugin that will clear up the allocation, used to determine the priority of the allocation
+void CMemoryMonitor::FreeOptionalRamL(TInt aBytesRequested, TInt aPluginId) // The ID of the plugin that will clear up the allocation, used to determine the priority of the allocation
{
FUNC_LOG;
iActionTrigger = EClientServerRequestOptionalRam;
- iDataPaged = aDataPaged;
-
// Calculate the priority of the allocation (the priority of the plugin that will clear it up - 1)
TInt priorityOfAllocation = iConfig->GetPluginConfig(aPluginId).CalculatePluginPriority(*iOomWindowGroupList) - 1;
- StartFreeSomeRamL(aBytesRequested + iGoodRamThreshold, iLowSwapThreshold, priorityOfAllocation);
+ StartFreeSomeRamL(aBytesRequested + iGoodThreshold, priorityOfAllocation);
}
void CMemoryMonitor::GetFreeMemory(TInt& aCurrentFreeMemory)
@@ -337,17 +308,6 @@
TRACES1("CMemoryMonitor::GetFreeMemory: Free RAM now %d", aCurrentFreeMemory);
}
-void CMemoryMonitor::GetFreeSwapSpace(TInt& aCurrentFreeSwapSpace)
- {
- FUNC_LOG;
-
- SVMSwapInfo swapInfo;
- UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo, 0);
- aCurrentFreeSwapSpace = swapInfo.iSwapFree;
-
- TRACES1("CMemoryMonitor::GetFreeSwapSpace: Free swap space now %d", aCurrentFreeSwapSpace);
- }
-
#ifndef CLIENT_REQUEST_QUEUE
TInt CMemoryMonitor::WatchdogStatusStatusChanged(TAny* aPtr)
{
@@ -398,11 +358,9 @@
iOomWindowGroupList->Refresh();
// Calculate the desired good threshold, this could be the globally configured value...
- iGoodRamThreshold = CMemoryMonitor::GlobalConfig().iGoodRamThreshold;
- iLowRamThreshold = CMemoryMonitor::GlobalConfig().iLowRamThreshold;
- iGoodSwapThreshold = CMemoryMonitor::GlobalConfig().iGoodSwapThreshold;
- iLowSwapThreshold = CMemoryMonitor::GlobalConfig().iLowSwapThreshold;
- TRACES4("CMemoryMonitor::RefreshThresholds: Global Good Ram Threshold = %d, Global Low Ram Threshold = %d, Global Good Swap Threshold = %d, Global Low Swap Threshold = %d", iGoodRamThreshold, iLowRamThreshold, iGoodSwapThreshold, iLowSwapThreshold);
+ iGoodThreshold = CMemoryMonitor::GlobalConfig().iGoodRamThreshold;
+ iLowThreshold = CMemoryMonitor::GlobalConfig().iLowRamThreshold;
+ TRACES2("CMemoryMonitor::RefreshThresholds: Global Good Threshold = %d, Global Low Threshold = %d", iGoodThreshold, iLowThreshold);
#ifdef _DEBUG
TRACES("CMemoryMonitor::RefreshThresholds: Dumping Window Group List");
@@ -435,27 +393,16 @@
// If this application configuration overrides the good_ram_threshold then set it
if (iConfig->GetApplicationConfig(foregroundAppId).iGoodRamThreshold != KOomThresholdUnset)
{
- iGoodRamThreshold = iConfig->GetApplicationConfig(foregroundAppId).iGoodRamThreshold;
- TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Good Ram Threshold = %d", foregroundAppId, iGoodRamThreshold);
+ iGoodThreshold = iConfig->GetApplicationConfig(foregroundAppId).iGoodRamThreshold;
+ TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Good Threshold = %d", foregroundAppId, iGoodThreshold);
}
// If this application configuration overrides the low_ram_threshold then set it
if (iConfig->GetApplicationConfig(foregroundAppId).iLowRamThreshold != KOomThresholdUnset)
{
- iLowRamThreshold = iConfig->GetApplicationConfig(foregroundAppId).iLowRamThreshold;
- TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Low Ram Threshold = %d", foregroundAppId, iLowRamThreshold);
+ iLowThreshold = iConfig->GetApplicationConfig(foregroundAppId).iLowRamThreshold;
+ TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Low Threshold = %d", foregroundAppId, iLowThreshold);
}
- if (iConfig->GetApplicationConfig(foregroundAppId).iGoodSwapThreshold != KOomThresholdUnset)
- {
- iGoodSwapThreshold = iConfig->GetApplicationConfig(foregroundAppId).iGoodSwapThreshold;
- TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Good Swap Threshold = %d", foregroundAppId, iGoodSwapThreshold);
- }
- // If this application configuration overrides the low_swap_threshold then set it
- if (iConfig->GetApplicationConfig(foregroundAppId).iLowSwapThreshold != KOomThresholdUnset)
- {
- iLowSwapThreshold = iConfig->GetApplicationConfig(foregroundAppId).iLowSwapThreshold;
- TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Low Swap Threshold = %d", foregroundAppId, iLowSwapThreshold);
- }
}
}
@@ -476,9 +423,8 @@
//we reset the target when a memory free operation completes, to deal with the case
//where the operation was initiated with a target larger than the current good threshold
- iCurrentRamTarget = iGoodRamThreshold;
- iCurrentSwapTarget = iGoodSwapThreshold;
- iOomActionList->SetCurrentTargets(iCurrentRamTarget, iCurrentSwapTarget);
+ iCurrentTarget = iGoodThreshold;
+ iOomActionList->SetCurrentTarget(iCurrentTarget);
}
void CMemoryMonitor::SetPriorityBusy(TInt aWgId)
@@ -506,14 +452,14 @@
}
#ifdef CLIENT_REQUEST_QUEUE
-TInt CMemoryMonitor::GoodRamThreshold() const
+TInt CMemoryMonitor::GoodThreshold() const
{
- return iGoodRamThreshold;
+ return iGoodThreshold;
}
-TInt CMemoryMonitor::LowRamThreshold() const
+TInt CMemoryMonitor::LowThreshold() const
{
- return iLowRamThreshold;
+ return iLowThreshold;
}
void CMemoryMonitor::ActionsCompleted(TInt aBytesFree, TBool aMemoryGood)