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 |
|
121
|
42 |
// Need this horrible construct because RVCT4 complains that the return is
|
|
43 |
// unreachable code. Without it, though, other code analysers will complain
|
|
44 |
// that there is a missing return value!
|
|
45 |
volatile TInt forever = 1;
|
|
46 |
|
|
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 |
}
|