|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE task |
|
11 PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"> |
|
12 <task id="GUID-0185D5DC-5142-42C3-8FFB-8EB76D49AB06" xml:lang="en"><title>Requesting |
|
13 RAM Synchronously</title><shortdesc>This section describes how an application can request for free |
|
14 RAM synchronously.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> |
|
15 <prereq id="GUID-CCF15EAF-F053-4968-AF9F-F9D0345F9F36"><p>Perform the steps |
|
16 described in <xref href="GUID-50CA5439-29A1-426C-83BA-EC048FE86CDE.dita">Allowing |
|
17 Large Memory Allocation</xref>.</p></prereq> |
|
18 <context id="GUID-BFCBBCAE-9FD9-4549-86E9-48294E896D32"> <p>Requesting |
|
19 free RAM synchronously is easy to implement because no active object is needed |
|
20 and is recommended when there is no need to perform any other task while waiting |
|
21 for the request to complete. This approach is not recommended in case of a |
|
22 server, as synchronous call blocks the server and it cannot serve its clients |
|
23 during synchronous wait.</p> </context> |
|
24 <steps id="GUID-4DD07DEC-6017-4237-BE46-1D69E5FBD744-GENID-1-8-1-10-1-1-8-1-5-1-6-1-6-1-6-1-3-3"> |
|
25 <step id="GUID-9A69E5AD-E938-4092-A8C2-CB65C37C8962-GENID-1-8-1-10-1-1-8-1-5-1-6-1-6-1-6-1-3-3-1"><cmd>Request free memory.</cmd> |
|
26 <info> <codeblock xml:space="preserve">User::LeaveIfError(iOomMonitorSession.RequestFreeMemory(KLargeValueToAllocate)); |
|
27 DoFunctionRequiring_KLargeValueToAllocate_Bytes();</codeblock> </info> |
|
28 </step> |
|
29 </steps> |
|
30 <example><p>The following code snippet illustrates an synchronous request |
|
31 for 2MB RAM: </p><codeblock xml:space="preserve">TInt KLargeValueToAllocate = 2097152; //2MB |
|
32 |
|
33 // Create an OOM Monitor session |
|
34 ROomMonitorSession oomMonitorSession; |
|
35 CleanUpClosePushL(oomMonitorSession); |
|
36 User::LeaveIfError(oomMonitorSession.Connect()); |
|
37 |
|
38 // Request free memory |
|
39 User::LeaveIfError(iOomMonitorSession.RequestFreeMemory(KLargeValueToAllocate)); |
|
40 DoFunctionRequiring_KLargeValueToAllocate_Bytes(); |
|
41 |
|
42 // Tidy up |
|
43 CleanupStack::PopAndDestroy(); //oomMonitorSession, calls Close() |
|
44 </codeblock></example> |
|
45 </taskbody><related-links> |
|
46 <link href="GUID-CE308C71-D8B2-43B3-97FD-B868285ED5FB.dita"><linktext>OOM Monitor |
|
47 Priority</linktext></link> |
|
48 <link href="GUID-39A8FBC9-5FD6-4F92-B71E-5C5438ECFD46.dita"><linktext>OOM Monitor |
|
49 Overview</linktext></link> |
|
50 <link href="GUID-88752800-83BD-4845-80A0-6B65D8D81924.dita"><linktext>OOM Monitor |
|
51 Reference</linktext></link> |
|
52 </related-links></task> |