Symbian3/SDK/Source/GUID-0185D5DC-5142-42C3-8FFB-8EB76D49AB06.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE task
  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-0185D5DC-5142-42C3-8FFB-8EB76D49AB06" xml:lang="en"><title>Requesting
RAM Synchronously</title><shortdesc>This section describes how an application can request for free
RAM synchronously.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<prereq id="GUID-CCF15EAF-F053-4968-AF9F-F9D0345F9F36"><p>Perform the steps
described in <xref href="GUID-50CA5439-29A1-426C-83BA-EC048FE86CDE.dita">Allowing
Large Memory Allocation</xref>.</p></prereq>
<context id="GUID-BFCBBCAE-9FD9-4549-86E9-48294E896D32">       <p>Requesting
free RAM synchronously is easy to implement because no active object is needed
and is recommended when there is no need to perform any other task while waiting
for the request to complete. This approach is not recommended in case of a
server, as synchronous call blocks the server and it cannot serve its clients
during synchronous wait.</p>     </context>
<steps id="GUID-4DD07DEC-6017-4237-BE46-1D69E5FBD744-GENID-1-10-1-10-1-1-8-1-5-1-6-1-6-1-6-1-3-3">
<step id="GUID-9A69E5AD-E938-4092-A8C2-CB65C37C8962-GENID-1-10-1-10-1-1-8-1-5-1-6-1-6-1-6-1-3-3-1"><cmd>Request free memory.</cmd>
<info>           <codeblock xml:space="preserve">User::LeaveIfError(iOomMonitorSession.RequestFreeMemory(KLargeValueToAllocate));
DoFunctionRequiring_KLargeValueToAllocate_Bytes();</codeblock>         </info>
</step>
</steps>
<example><p>The following code snippet illustrates an synchronous request
for 2MB RAM: </p><codeblock xml:space="preserve">TInt KLargeValueToAllocate = 2097152; //2MB

// Create an OOM Monitor session
ROomMonitorSession oomMonitorSession;
CleanUpClosePushL(oomMonitorSession);
User::LeaveIfError(oomMonitorSession.Connect());

// Request free memory
User::LeaveIfError(iOomMonitorSession.RequestFreeMemory(KLargeValueToAllocate));
DoFunctionRequiring_KLargeValueToAllocate_Bytes();

// Tidy up
CleanupStack::PopAndDestroy(); //oomMonitorSession, calls Close()
</codeblock></example>
</taskbody><related-links>
<link href="GUID-CE308C71-D8B2-43B3-97FD-B868285ED5FB.dita"><linktext>OOM Monitor
Priority</linktext></link>
<link href="GUID-39A8FBC9-5FD6-4F92-B71E-5C5438ECFD46.dita"><linktext>OOM Monitor
Overview</linktext></link>
<link href="GUID-88752800-83BD-4845-80A0-6B65D8D81924.dita"><linktext>OOM Monitor
Reference</linktext></link>
</related-links></task>