OOM Monitor Client API: API description

Overview

This section provides you with an overview of the Out of Memory Monitor Client API features.

General functionality

The basic function of the OOM Monitor is to monitor the amount of free RAM in the mobile device. Whenever the amount of free RAM decreases below a defined LOW_RAM_THRESHOLD threshold value, the OOM Monitor is triggered and it releases RAM by closing applications running on background in order to raise the amount of free RAM above a defined GOOD_RAM_THRESHOLD treshold value. These two configurable thresholds (LOW_RAM_THRESHOLD and GOOD_RAM_THRESHOLD) exist to provide a hysteresis and thus ensuring sufficient amount of free RAM in the mobile device.

Figure 1: Overview of the OOM Monitor Functionality

Whenever the amount of free RAM decreases below LOW_RAM_THRESHOLD the OOM Monitor releases RAM by closing applications which are not deemed to be in connection with the active applications. This process is called as normal RAM rotation.

Figure 2: OOM hysteresis in a normal RAM rotation.

Out of Memory Priority

The OOM priority

When releasing RAM the OOM Monitor uses priorities to determine the order of closing the applications. Each application is assigned with a priority which determines the order (in relation to other applications) of closing the application.

A priority of an application is a measure of impact to the mobile device user in case the OOM Monitor closes that application. Thus a low priority means that the closing of that application will have a low impact on the user, whereas a high priority means that the closing will have a high impact on the user.

The OOM Monitor closes the lowest priority application first (as this will have the smallest impact on the user), then the second lowest, etc. until the amount of the free RAM has risen above the GOOD_RAM_TRESHOLD value.

If two or more applications have the same priority the OOM Monitor closes these applications based on their idle time (i.e. the time the application has stayed idle in the background) in the following order:

  1. The longest idle time
  2. The second longest idle time
  3. etc.

The priority of each internal and 3rd party S60 application is defined in the OOM Monitor configuration file which is set up for each device.

3rd party applications can use he following priorities:

By default 3rd party applications' priority is Normal but any 3rd party application can change its own priority by using the Out of Memory Monitor Client API.

The OOM Monitor can never close a foreground application. For this reason it can be said that the priority of the foreground application is Busy. The mobile device user can also define the Busy priority for background applications which means that those applications are never closed by the OOM Monitor.

Dynamic rules for changing the priority

The OOM Monitor configuration file can contain rules which determine how the OOM Monitor changes the priority of one or many applications. The changing of the priority is based on two following issues:

Changing the priority with OOM Monitor Client API

An application can change its OOM priority by calling the OOM Monitor Client API's void SetOomPriority() method. For more information, see allowing an application to protect itself from closing by the OOM Monitor.

Characteristics of void SetOomPriority(TOomPriority aPriority) method's TOomPriority parameter values

When to use the OOM Monitor Client API?

The OOM Monitor Client API is meant to be used in the following two cases:

How to avoid out-of-RAM error in applications

To avoid a situation where the free RAM would run out because applications allocated the RAM faster than the OOM Monitor released it, the OOM Monitor has the KOomMaxAllocationWithoutPermission constant. It defines the maximum amount of RAM that an application can safely allocate within two seconds without first asking permission from OOM Monitor.

The KOomMaxAllocationWithoutPermission value defined in the OOM Monitor header file will not be decreased in the future, so allocating not over KOomMaxAllocationWithoutPermission amount of RAM is safe. The RAM can be allocated quickly in small pieces as long as the total amount of allocated RAM within two seconds is less than KOomMaxAllocationWithoutPermission.

Out-of-RAM error in normal RAM rotation

An application should always be prepared for an out-of-RAM error because it can still occur for example in the following situations:

Use cases

The use cases for the Out of Memory Monitor Client API demonstrate how to

API class structure

The Out of Memory Monitor Client API consists of ROomMonitorSession class whose class definition is as follows:

class ROomMonitorSession : public RSessionBase
ROomMonitorSession class has


Copyright © Nokia Corporation 2001-2008
Back to top