ROomMonitorSession Class Reference

Link against: oommonitor.lib


#include <
oommonitorclient.h>

Detailed Description

The client interface for OOM (Out Of Memory) monitor.

Usage:

 #include <oommonitorclient.h>

 // Client application connects session to the OOM Monitor.
 // 'iOomMonitor' is an instance of ROomMonitorSession.
 User::LeaveIfError( iOomMonitor.Connect() );
 // ...

 // The client requests permission to allocate big amount of memory safely.

 // The client requests permission to allocate free memory safely.
 // 'KBigBlockSize' contains size greater than 
 // 'KOomMaxAllocationWithoutPermission' and 'err' indicates 
 // if there is memory to be allocated or not.
 TInt err = iOomMonitor.RequestFreeMemory( KBigBlockSize );

 // The client allocates the memory if permission was granted.
 // 'iPtr' stores pointer to allocated memory.
 if ( err == KErrNone )
    {
    iPtr = User::AllocL( KBigBlockSize );
    }
 // ...


 // If the client is occasionally doing something for the user in the background, 
 // it can be protected from being closed during the time when the active task 
 // is ongoing.
 iOomMonitor.SetPriority( ROomMonitorSession::EOomPriorityBusy );

 // Do something that continues when this application is in the background.

 // When the client finishes its background job, protection is no longer needed.
 iOomMonitor.SetPriority( ROomMonitorSession::EOomPriorityNormal );
 // ...


 // The client closes the OOM Monitor session
 iOomMonitor.Close();
Dll oommonitor.lib

Public Types

enum  TOomPriority { EOomPriorityNormal = 0, EOomPriorityHigh, EOomPriorityBusy }
 Defines the application priorities of OOM monitor. More...

Public Member Functions

IMPORT_C TInt Connect ()
 Connects a new session.
IMPORT_C TInt RequestFreeMemory (TInt aBytesRequested)
 Request that the OOM monitor attempts to free some memory.
IMPORT_C void RequestFreeMemory (TInt aBytesRequested, TRequestStatus &aStatus)
 Request that the OOM monitor attempts to free some memory.
IMPORT_C void CancelRequestFreeMemory ()
 Cancels the asynchronous request for free memory.
IMPORT_C void SetOomPriority (TOomPriority aPriority)
 Notify the OOM monitor that this application has the specified priority.

Member Enumeration Documentation

enum ROomMonitorSession::TOomPriority
 

Defines the application priorities of OOM monitor.

Enumerator:
EOomPriorityNormal  Application can be closed if needed.
EOomPriorityHigh  Application should not be closed if possible.
EOomPriorityBusy  Application is busy and should not be closed.

Member Function Documentation

IMPORT_C void ROomMonitorSession::CancelRequestFreeMemory  ) 
 

Cancels the asynchronous request for free memory.

IMPORT_C TInt ROomMonitorSession::Connect  ) 
 

Connects a new session.

Sessions must be connected before any other APIs can be used. When the client has finished using a session, Close() must be called.

Returns:
KErrNone if successful, error code otherwise.
IMPORT_C void ROomMonitorSession::RequestFreeMemory TInt  aBytesRequested,
TRequestStatus &  aStatus
 

Request that the OOM monitor attempts to free some memory.

This is an asynchronous version of the request for free memory.

Parameters:
aBytesRequested The number of bytes of free memory that the client requests.
aStatus will be completed when the attempt to recover memory has finished. This may take several seconds, depending on the memory state. On completion, aStatus will be set to KErrNone if the request memory is free. KErrNoMemory if that amount of memory could not be recovered. Other error codes may also be set.
IMPORT_C TInt ROomMonitorSession::RequestFreeMemory TInt  aBytesRequested  ) 
 

Request that the OOM monitor attempts to free some memory.

This function may take several seconds to execute, depending on the memory state. It will not return until the attempt to recover memory has completed.

Parameters:
aBytesRequested The number of bytes of free memory that the client requests.
Returns:
KErrNone if the request memory is free. KErrNoMemory if that amount of memory could not be recovered. Other error codes may also be returned.
IMPORT_C void ROomMonitorSession::SetOomPriority TOomPriority  aPriority  ) 
 

Notify the OOM monitor that this application has the specified priority.

Parameters:
aPriority the priority of the application

The documentation for this class was generated from the following file:

Copyright © Nokia Corporation 2001-2007
Back to top