kerneltest/e32test/heap/t_hcomp.cpp
changeset 0 a41df078684a
child 109 b3a1d9898418
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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 
       
    42 	FOREVER
       
    43 		{
       
    44 		TUint8* ptr=(TUint8*)heap1->Alloc(heapsize);	// fail, compress, fail
       
    45 		User::After(1000);	// quite soon
       
    46 		heap1->Free(ptr);
       
    47 		}
       
    48 	return 0;
       
    49 	}