1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html> 3<head> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META http-equiv="Content-Style-Type" content="text/css"> 6<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css"> 7<title>MEM Demos</title> 8</head> 9 10<body> 11 12<h1>MEM Demos</h1> 13<H2>How to Compile</H2> 14<P> 15Go to <CODE>$REVOLUTION_SDK_ROOT/build/demos/memdemo</CODE> and enter <CODE>make</CODE>. The executable program (<CODE>.elf</CODE> file) is generated under <CODE>$REVOLUTION_SDK_ROOT/build/demos/memdemo/bin/RVL/</CODE>. 16</P> 17 18<H2>Execution</H2> 19<P> 20Setting up <CODE>DVDRoot</CODE> is not required because the optical disc is not accessed.<BR>Load the generated <CODE>.elf</CODE> file in the <CODE>$REVOLUTION_SDK_ROOT//build/demos/memdemo/bin/RVL/</CODE> directory. 21 22<H2>Description</H2> 23<P>The following example uses the <CODE>OSReport</CODE> function to output results with debug print. Nothing is output onscreen.<BR>There are some sections where the valid <CODE>MEMDumpHeap</CODE> function is used only for debug building, so the output for debug building differs slightly from non debug building. <BR> 24</P> 25<TABLE border="1" cellpadding="3" cellspacing="0.1"> 26 <TBODY> 27 <TR> 28<TD><CODE>exp-1</CODE></TD> 29<TD>This example creates an expanded heap to allocate and free memory.<BR>The total size of memory allocated from the top of the heap is calculated using the visitor function, and processing is performed to free all memory for each group ID. 30 </TD> 31 </TR> 32 <TR> 33<TD><CODE>frm-1</CODE></TD> 34<TD>This example creates a frame heap to allocate and free memory, and restore the original status.<BR>First, an expanded heap is created in the arena; a frame heap is then created in memory allocated from this expanded heap.<BR>The size of the frame heap is reduced using the <a href="FrmHeap/MEMAdjustFrmHeap.html"><CODE>MEMAdjustFrmHeap</CODE></a> function. Any extra memory is returned to the expanded heap of the parent heap. 35 </TD> 36 </TR> 37 <TR> 38<TD><CODE>unit-1</CODE></TD> 39<TD>This example creates a unit heap to allocate and free memory.<BR>64 bytes are handled as a unit block. 40 </TD> 41 </TR> 42 <TR> 43<TD><CODE>allocator</CODE></TD> 44<TD>This example creates an allocator from various heaps to allocate and free memory.<BR>Create an extended, frame, unit, and OS heap, and then create an allocator from each of these heaps to be provided with a common interface between the heaps. <BR> However, the unit heap allocator can't allocate blocks of memory greater than the block size. Furthermore, the frame heap allocator doesn't free memory. 45 46 </TD> 47 </TR> 48 <TR> 49<TD><CODE>thread_safe</CODE></TD> 50<TD>This example checks the thread-safe feature of the heap.<BR>Specify the <CODE>MEM_HEAP_OPT_THREAD_SAFE</CODE> option at heap creation to enable the thread-safe feature of the heap. <BR>A thread that periodically executes according to an alarm and the main thread repeatedly allocates and frees memory.<BR>START outputs the current heap content. 51 </TD> 52 </TR> 53 </TBODY> 54</TABLE> 55 56<h2>See Also</h2> 57 58<H2>Revision History</H2> 59<P>03/01/2006 Initial version. <BR></P> 60</body> 61 62</html> 63