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>Functionality Common Among the Different Heaps</TITLE>
8<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css">
9</HEAD>
10<BODY>
11
12<H1>Functionality Common Among the Different Heaps</H1>
13<p>
14This section describes the functionality common among the expanded, frame, and unit heap.
15</p>
16
17<H2>Heap Options</H2>
18<p>
19Among the functions that can be used to create a heap, heap options can be specified using <A HREF="./ExpHeap/MEMCreateExpHeapEx.html"><CODE>MEMCreateExpHeapEx</CODE></A>, <A HREF="./FrmHeap/MEMCreateFrmHeapEx.html"><CODE>MEMCreateFrmHeapEx</CODE></A> and <A HREF="./UnitHeap/MEMCreateUnitHeapEx.html"><CODE>MEMCreateUnitHeapEx</CODE></A>. The following are options that can be specified.
20</p>
21
22<TABLE border="1"><CAPTION>Options That Can Be Specified During Heap Creation</CAPTION>
23<TR><TD>Flag</TD><TD>Description</TD></TR>
24<TR><TD><CODE>MEM_HEAP_OPT_0_CLEAR</CODE></TD><TD>The allocated memory block is filled with zeroes upon allocation from the heap.</TD></TR>
25<TR><TD><CODE>MEM_HEAP_OPT_DEBUG_FILL</CODE></TD><TD>At heap creation and/or at memory block allocation and freeing, the memory region is filled with different 32-bit values.</TD></TR>
26<TR><TD><CODE>MEM_HEAP_OPT_THREAD_SAFE</CODE></TD><TD>Enables exclusive processing between threads.</TD></TR>
27</TABLE>
28
29<p>
30The <CODE>MEM_HEAP_OPT_DEBUG_FILL</CODE> flag is used for debugging. Use this flag to find memory access bugs by tracing the pointer that points to the memory initialization failure or invalid memory regions. This flag will not function in the final ROM version of the library. The following values fill in memory regions by default. See the next section to learn how to change these values.
31</p>
32<UL>
33<LI>At time of heap creation: 0xC3C3C3C3
34<LI>At time of memory allocation: 0xF3F3F3F3
35<LI>At time of memory freeing: 0xD3D3D3D3
36</UL>
37
38<H2>Changing Fill Values for Debugging</H2>
39<p>
40By specifying the <CODE>MEM_HEAP_OPT_DEBUG_FILL</CODE> flag when creating the heap, the memory region can be filled with a different 32-bit value during heap creation, memory block allocation and freeing, respectively. This fill value can be modified. You can set and get the fill values using the following functions.
41</p>
42
43<TABLE border="1"><CAPTION>Functions for Setting and Getting Debug Fill Values</CAPTION>
44<TR><TD>Function</TD><TD>Description</TD></TR>
45<TR><TD><A HREF="./Heap/MEMSetFillValForHeap.html"><CODE>MEMSetFillValForHeap</CODE></A></TD><TD>Sets fill values.</TD></TR>
46<TR><TD><A HREF="./Heap/MEMGetFillValForHeap.html"><CODE>MEMGetFillValForHeap</CODE></A></TD><TD>Gets fill values.</TD></TR>
47</TABLE>
48
49<p>
50Different values can be set when heaps are created, memory blocks are allocated, and memory blocks are freed. When you set or get values, the heap operation the values are specific to is set. The following table shows the types of heap operations specified in the function.
51</p>
52
53<TABLE border="1"><CAPTION>Types of Heap Operations for Fill Values</CAPTION>
54<TR><TD>Value Specified in the Function</TD><TD>Heap Operation</TD></TR>
55<TR><TD><CODE>MEM_HEAP_FILL_NOUSE</CODE></TD><TD>At heap creation.</TD></TR>
56<TR><TD><CODE>MEM_HEAP_FILL_ALLOC</CODE></TD><TD>At memory block allocation.</TD></TR>
57<TR><TD><CODE>MEM_HEAP_FILL_FREE</CODE></TD><TD>At memory block freeing.</TD></TR>
58</TABLE>
59
60<H2>Displaying Heap Content</H2>
61<p>
62This feature for displaying the content of the heap is for debugging. The following functions accomplish this.
63</p>
64
65<TABLE border="1"><CAPTION>Functions that Display Internal Heap Data</CAPTION>
66<TR><TD>Function</TD><TD>Description</TD></TR>
67<TR><TD><A HREF="./Heap/MEMDumpHeap.html"><CODE>MEMDumpHeap</CODE></A></TD><TD>Displays internal heap data.</TD></TR>
68</TABLE>
69
70<H2>Getting Heap Regions</H2>
71<p>
72This feature obtains the start and end address of memory regions used by the heaps. The following functions accomplish this.
73</p>
74
75<TABLE border="1"><CAPTION>Functions for Getting the Heap Region</CAPTION>
76<TR><TD>Function</TD><TD>Description</TD></TR>
77<TR><TD><A HREF="./Heap/MEMGetHeapStartAddress.html"><CODE>MEMGetHeapStartAddress</CODE></A></TD><TD>Gets the starting address of the memory region used by the heap.</TD></TR>
78<TR><TD><A HREF="./Heap/MEMGetHeapEndAddress.html"><CODE>MEMGetHeapEndAddress</CODE></A></TD><TD>Gets the ending address + 1 of the memory region used by the heap.</TD></TR>
79</TABLE>
80
81<H2>Revision History</H2>
82<P>03/01/2006 Initial version.</P>
83</BODY>
84</HTML>
85