Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions codeless banner

OomManager Class Reference
[QtBaseModule, QtDevToolsModule]

The OomManager class manages low and out of memory situations. More...

    #include <OomManager>

Inherits QObject.

Public Types

Public Functions

Additional Inherited Members


Detailed Description

The OomManager class manages low and out of memory situations.

This class is a wrapper for the Out-of-memory manager. It is used in sublasses of the ApplicationTypeLauncher class that launch applications as linux processes. It is also used in ApplicationLauncher and LowMemoryTask.

This class contains three sets of application names. The first set is called critical. It contains the names of all the Qt Extended applications that must not be killed, when Qt Extended runs out of memory, eg Qt Extended itself (qpe) is in the critical set.

The second set is called expendable. It contains the names of the applications that the user wants killed first, when Qt Extended runs out of memory.

The third set is called important. It contains the names of applications the user wants to avoid killing, if possible, when Qt Extended runs out of memory. Important processes will not be killed if there are expendable processes running, but expendable processes can be killed. Only critical processes are not killable.

All this data is read from a configuration file called oom.conf. The user can create oom.conf with a text editor. Here is an example:

    [oom_adj]
    qpe=critical
    qasteroids=expendable
    fifteen=expendable
    minesweep=expendable
    snake=expendable
    calculator=important
    clock=important
    datebook=important

    [values]
    critical=250
    verylow=120
    low=60
    samples=5
    percent=20
    long=10000
    short=1000
    rlimit=32

Whenever a new process achieves the running state, its name and pid are inserted into a map here. Additionally, the process's oom_adj value is set here according to whether the process is critical, expendable, or important. The oom_adj value is used by the linux kernel to help it determine which processes to kill when a hard out-of-memory condition occurs. The oom_adj value is stored in /proc/<pid>/oom_adj.

Note: All OomManager instances share the same internal list of applications.

This class is part of the Qt Extended server and cannot be used by other Qt Extended applications.


Member Type Documentation

enum OomManager::Importance

This enum is used to describe the various application priority as seen by the OOM Manager.

ConstantValueDescription
OomManager::Expendable0Expendable applications have lowest priority and will be killed first.
OomManager::Important1Important applications should only be killed if no expendable applications are left to be killed.
OomManager::Critical2Critical applications cannot be killed.


Member Function Documentation

OomManager::OomManager ()

This constrcutor creates a new OomManager instance.

OomManager::~OomManager ()

Destroys the OomManager instance.

const QMap<QString, int> & OomManager::expendableProcs () const

Returns a reference to the map of expendable processes. that maps application name to process id. The map can be empty.

bool OomManager::hasExpendableProcs () const

Returns true if at least one of the running process is marked as being expendable.

bool OomManager::hasImportantProcs () const

Returns true if at least one of the running process is marked as being important.

const QMap<QString, int> & OomManager::importantProcs () const

Returns a reference to the map of important processes. that maps application name to process id. The map can be empty.

void OomManager::insert ( const QString & app, int pid )

Insert a mapping from app to pid. The process pid must be in the running state, and it must be an instance of app. This function must be called when process pid enters the running state.

The value in /proc/pid/oom_adj is set to a value read from oom.conf according to whether the process is a critical, expendable, or important process.

bool OomManager::isExpendable ( const QString & app ) const

Returns true if app is not marked important or critical.

bool OomManager::isImportant ( const QString & app ) const

Returns true if app is marked important.

QString OomManager::procWithBiggestScore ( Importance t ) const

Returns the application name of the process marked as t that has the biggest OOM score.

void OomManager::remove ( const QString & app )

Remove the mapping from application app to its process id. This function must be called for any linux process started by the ApplicationLauncher, when the process is terminated for any reason.


Copyright © 2009 Nokia Trademarks
Qt Extended 4.4.3