Link against: oommonitor.lib
#include <oommonitorclient.h>
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();
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. |
|
Defines the application priorities of OOM monitor. |
|
Cancels the asynchronous request for free memory. |
|
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.
|
|
Request that the OOM monitor attempts to free some memory. This is an asynchronous version of the request for free memory.
|
|
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.
|
|
Notify the OOM monitor that this application has the specified priority.
|