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 Sample Demos</title> 8</head> 9 10<body> 11 12<h1>Memory Management (MEM) Sample Demos</h1> 13 14<H2>Compilation</H2> 15<P> 16Navigate to <CODE>$REVOLUTION_SDK_ROOT/build/demos/memdemo</CODE> and enter <CODE>make</CODE>.<BR>The executable (<CODE>.elf</CODE>) files are generated in the <CODE>$REVOLUTION_SDK_ROOT/build/demos/memdemo/bin/RVL/</CODE> directory. 17</P> 18 19<H2>Execution</H2> 20<P> 21Setting 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.</P> 22 23<H2>Description</H2> 24<P>The following samples use the <CODE>OSReport</CODE> function to output results with debug print. Nothing is output onscreen.<BR>There are some sections which use the <a href="Heap/MEMDumpHeap.html"><CODE>MEMDumpHeap</CODE></A> function, which is valid only in debug builds, so the output for debug builds differs slightly from non-debug builds.<BR> 25</P> 26<TABLE class="demo_list" border="1" > 27 <TBODY> 28 <TR> 29<TH>exp-1</TH> 30<TD>This example creates an expanded heap to allocate and deallocate memory.<BR>The total size of memory allocated from the top of the heap is calculated using the <CODE>visitor</CODE> function, and processing is performed to deallocate all memory for each group ID. 31 </TD> 32 </TR> 33 <TR> 34<TH>frm-1</TH> 35<TD>This example creates a frame heap, allocates and deallocates memory and restores memory to its 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. 36 </TD> 37 </TR> 38 <TR> 39<TH>unit-1</TH> 40<TD>This example creates a unit heap to allocate and deallocate memory.<BR>64 bytes are handled as a single unit block. 41 </TD> 42 </TR> 43 <TR> 44<TH>allocator</TH> 45<TD>This example creates an allocator from the various heaps and uses it to allocate and deallocate memory.<BR>Creates an extended heap, frame heap, unit heap and OS heap, and then creates an allocator from each of these heaps, which allows it to provide a common interface independent of heap type.<BR>However, allocators created from the unit heap can't allocate blocks of memory greater than the block size, and allocators created from the frame heap do not deallocate memory. 46 </TD> 47 </TR> 48 <TR> 49<TH>thread_safe</TH> 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>This example infinitely runs a thread that is periodically started up according to an alarm and repeatedly allocates and deallocates memory in the main thread.<BR>The START Button outputs the current heap content. 51 </TD> 52 </TR> 53 </TBODY> 54</TABLE> 55 56<h2>See Also</h2> 57<P>None.</P> 58 59<H2>Revision History</H2> 60<P> 612006/03/01 Initial version.<br> 62</P> 63 64<hr><p>CONFIDENTIAL</p></body> 65 66</html> 67