author | Mike Kinghan <mikek@symbian.org> |
Thu, 25 Nov 2010 14:35:45 +0000 | |
branch | GCC_SURGE |
changeset 305 | 1ba12ef4ef89 |
parent 109 | b3a1d9898418 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// e32test\heap\t_hcomp.cpp |
|
15 |
// Causes lots of chunk compression without using much memory |
|
16 |
// Won't work on WINS unless memory allocation limits are set. |
|
17 |
// |
|
18 |
// |
|
19 |
||
20 |
||
21 |
#include <e32std.h> |
|
22 |
#include <e32std_private.h> |
|
23 |
#include <e32hal.h> |
|
24 |
||
25 |
const TUint size64k = 64*1024; |
|
26 |
||
27 |
GLDEF_C TInt E32Main() |
|
28 |
{ |
|
29 |
||
30 |
RProcess me; |
|
31 |
me.SetPriority(EPriorityHigh); |
|
32 |
||
33 |
TMemoryInfoV1Buf membuf; |
|
34 |
UserHal::MemoryInfo(membuf); |
|
35 |
TInt maxmem=membuf().iTotalRamInBytes; |
|
36 |
TInt heapsize=maxmem*2; |
|
37 |
||
38 |
RHeap* heap1=User::ChunkHeap(NULL,size64k,heapsize+size64k); |
|
39 |
if (heap1==NULL) |
|
40 |
return KErrNoMemory; |
|
41 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
42 |
// Need this horrible construct because RVCT4 complains that the return is |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
43 |
// unreachable code. Without it, though, other code analysers will complain |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
44 |
// that there is a missing return value! |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
45 |
volatile TInt forever = 1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
while(forever) |
0 | 48 |
{ |
49 |
TUint8* ptr=(TUint8*)heap1->Alloc(heapsize); // fail, compress, fail |
|
50 |
User::After(1000); // quite soon |
|
51 |
heap1->Free(ptr); |
|
52 |
} |
|
53 |
return 0; |
|
54 |
} |