Memory Management (MEM) Sample Demos

Compilation

Navigate to $REVOLUTION_SDK_ROOT/build/demos/memdemo and enter make.
The executable (.elf) files are generated in the $REVOLUTION_SDK_ROOT/build/demos/memdemo/bin/RVL/ directory.

Execution

Setting up DVDRoot is not required because the optical disc is not accessed.
Load the generated .elf file in the $REVOLUTION_SDK_ROOT/build/demos/memdemo/bin/RVL/ directory.

Description

The following samples use the OSReport function to output results with debug print. Nothing is output onscreen.
There are some sections which use the MEMDumpHeap function, which is valid only in debug builds, so the output for debug builds differs slightly from non-debug builds.

exp-1 This example creates an expanded heap to allocate and deallocate memory.
The total size of memory allocated from the top of the heap is calculated using the visitor function, and processing is performed to deallocate all memory for each group ID.
frm-1 This example creates a frame heap, allocates and deallocates memory and restores memory to its original status.
First, an expanded heap is created in the arena; a frame heap is then created in memory allocated from this expanded heap.
The size of the frame heap is reduced using the MEMAdjustFrmHeap function. Any extra memory is returned to the expanded heap of the parent heap.
unit-1 This example creates a unit heap to allocate and deallocate memory.
64 bytes are handled as a single unit block.
allocator This example creates an allocator from the various heaps and uses it to allocate and deallocate memory.
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.
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.
thread_safe This example checks the thread-safe feature of the heap.
Specify the MEM_HEAP_OPT_THREAD_SAFE option at heap creation to enable the thread-safe feature of the heap.
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.
The START Button outputs the current heap content.

See Also

None.

Revision History

2006/03/01 Initial version.


CONFIDENTIAL