OOM Monitor Overview

This section provides an overview of the functionality and the architecture of the OOM Monitor component.

Purpose

The OOM Monitor Client API monitors the memory situations and handles out of memory situations. OOM monitor is responsible to maintain good memory level in the device. In case of low memory situation, OOM Monitor releases memory by closing applications based on the priority defined. For information on priority, refer to OOM Monitor Priority.

Key concepts

LOW_RAM_THRESHOLD

It is the minimum amount of free RAM that is specified for the device. This value must be specified in the monitor configuration file.

GOOD_RAM_THRESHOLD

It is the required amount of free RAM that is specified for the device. This value must be specified in the monitor configuration file.

Normal RAM rotation

Whenever the amount of free RAM decreases below LOW_RAM_THRESHOLD the OOM Monitor releases RAM by closing applications based on the priorities. This process is called as normal RAM rotation.

For information on OOM Monitor Priority and Optional RAM allocation, refer to OOM Monitor Concepts

Architecture

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. The OOM Monitor then releases RAM by closing applications running on background in order to raise the amount of free RAM above the defined GOOD_RAM_THRESHOLD value.

APIs

The OOM Monitor Client API consists of ROomMonitorSession class. The main functions of this class are:

Function

Description

RequestFreeMemory()

Requests the OOM monitor to allocate RAM.

SetOomPriority()

Sets the priority for an application as high, busy or normal. The application priorities must be defined in TOomPriority variable.

RequestOptionalRam()

Requests the OOM monitor to allocate optional RAM.

The OOM Monitor Client API also consists of COomMonitorPlugin class. The main functions of this plug-in class are:

Function

Description

FreeRam()

Requests to release RAM when the system RAM level becomes low.

MemoryGood()

Called when the system RAM level improves to good from low RAM situation. Once the memory level is good, the OOM plug-in can again start allocating optional RAM.

Typical Uses

Applications can use the following functionality provided by the OOM Monitor component to:

  • Safely allocate large amount of RAM. For more information, refer to Requesting for Large Memory Allocation.

  • Change its priority in order to protect itself from being closed by the OOM Monitor. For more information, refer to Changing the Priority.

  • Allocate optional RAM to applications when additional RAM is requested. For more information, refer to Requesting for Optional RAM Allocation.

  • Prevent OOM errors from happening by monitoring the amount of free RAM in the system. When the amount of free RAM drops below the specified threshold value, OOM Monitor automatically closes applications that are staying idle in the background in order to give more RAM to the applications that are active. For more information, refer to Out of Memory Error.

  • Assign priority for each action that can be used to release RAM (i.e. closing an application or calling an OOM plug-in). When releasing RAM, OOM Monitor uses the priorities to determine the order of closing applications and calling plug-ins. As a result RAM is always released by minimizing the negative impact to the user, provided the priorities are correctly configured for the device. For more information, refer to Priority Configuration.