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<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 8.0.0.0 for Windows">
7<TITLE>The Unit Heap Manager</TITLE>
8<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css">
9</HEAD>
10<BODY>
11
12<H1>The Unit Heap Manager</H1>
13<p>
14The Unit Heap Manager allocates only memory blocks with the size that is specified at the time that the unit heap is created. This memory manager is for allocating and deallocating memory blocks that have a fixed size. The unit heap does not have a management region for memory blocks which makes the heap more memory efficient. This section provides an overview of the Unit Heap Memory Manager.
15</p>
16
17<H2>Creating Heaps</H2>
18<p>
19To use the Unit Heap Manager, you must create a unit heap. The following functions create and destroy unit heaps.
20</p>
21
22<TABLE class="api_list" border="1">
23<CAPTION>Functions for Creating and Destroying Heaps</CAPTION>
24<TR><TD><B>Functions</B></TD><TD><B>Features</B></TD></TR>
25<TR><TH><A HREF="./UnitHeap/MEMCreateUnitHeap.html">MEMCreateUnitHeap</A></TH><TD>Creates the unit heap.</TD></TR>
26<TR><TH><A HREF="./UnitHeap/MEMCreateUnitHeapEx.html">MEMCreateUnitHeapEx</A></TH><TD>Creates the unit heap. Alignment and heap options can be specified.</TD></TR>
27<TR><TH><A HREF="./UnitHeap/MEMDestroyUnitHeap.html">MEMDestroyUnitHeap</A></TH><TD>Destorys the unit heap.</TD></TR>
28</TABLE>
29
30<H2>Allocating Memory Blocks</H2>
31<H3>Allocating and Freeing Memory Blocks</H3>
32<p>
33The Unit Heap Manager manages the heap regions in chunks of a specified size. Memory block allocation refers to allocating these chunks.
34</p>
35<p>
36Available chunks are linked as one linked list (free chunk list). The pointer to the next free chunk is placed at the starting address of the chunk. There aren't pointers for in use chunks. (There is also no management region.) When allocating memory blocks, the manager returns the memory block that is linked to the start address of this free chunk list. When freeing a memory block that is in use, the manager links the memory block to the start address of the available chunk list.
37</p>
38
39<CENTER><IMG SRC="./fig4-1.gif"><BR><B>Figure 4-1  Allocating Memory for the Unit Heap</B><BR></CENTER>
40
41<P>The following functions allocate and free memory blocks.</P>
42
43<TABLE class="api_list" border="1">
44<CAPTION>Functions for Allocating and Freeing Memory Blocks</CAPTION>
45<TR><TD><B>Functions</B></TD><TD><B>Features</B></TD></TR>
46<TR><TH><A HREF="./UnitHeap/MEMAllocFromUnitHeap.html">MEMAllocFromUnitHeap</A></TH><TD>Allocates a memory block from the unit heap.</TD></TR>
47<TR><TH><A HREF="./UnitHeap/MEMFreeToUnitHeap.html">MEMFreeToUnitHeap</A></TH><TD>Frees a memory block.</TD></TR>
48</TABLE>
49
50<H3>Allocating the Minimum Memory Block Size</H3>
51<p>
52Even though the Unit Heap Manager does not have a memory block management region, the minimum alignment of allocated memory blocks must be on a 4-byte boundary. Allocating a 1-byte memory block consumes 4 bytes of memory.
53</p>
54
55<H2>Specifying Alignment</H2>
56<p>
57The Unit Heap Manager can specify the alignment at heap creation. It does not do this for each allocated memory block. All allocated memory blocks will have the same alignment. In the <A HREF="./UnitHeap/MEMCreateUnitHeapEx.html"><CODE>MEMCreateUnitHeapEx</CODE></A> function, you can specify 4, 8, 16 or 32 as alignment values. The <A HREF="./UnitHeap/MEMCreateUnitHeap.html"><CODE>MEMCreateUnitHeap</CODE></A> function does not specify alignment; the alignment value is always a value of 4.
58</p>
59
60<H2>Acquiring the Number of Allocatable Memory Blocks</H2>
61<p>
62The Unit Heap Manager can get the number of allocatable memory blocks (in other words, the number of available chunks). Shown in the following function.
63</p>
64
65<TABLE class="api_list" border="1">
66<CAPTION>Function for Getting the Number of Allocatable Memory Blocks</CAPTION>
67<TR><TD><B>Functions</B></TD><TD><B>Features</B></TD></TR>
68<TR><TH><A HREF="./UnitHeap/MEMCountFreeBlockForUnitHeap.html">MEMCountFreeBlockForUnitHeap</A></TH><TD>Returns the number of allocatable memory blocks.</TD></TR>
69</TABLE>
70
71<H2>Revision History</H2>
72<P>
732006/03/01 Initial version.<BR>
74</P>
75
76<hr><p>CONFIDENTIAL</p></body>
77</HTML>
78