IBM C and C++ Compilers lets you create and use your own pools of memory, called heaps. You can use your own heaps in place of or in addition to the default IBM C and C++ Compilers runtime heap to improve the performance of your program.
Note: Many readers will not be interested in creating their own heaps. Using your own heaps is entirely optional, and your applications will work perfectly well using the default memory management provided (and used by) the IBM C and C++ Compilers runtime library. If you want to improve the performance and memory management of your program, multiple heaps can help you. Otherwise, you can ignore this section and any heap-specific library functions.
Why Use Multiple Heaps?
Using a single runtime heap is fine for most programs. However, using multiple heaps can be more efficient and can help you improve your program's performance and reduce wasted memory for a number of reasons:
With multiple heaps, you can specify which heap you allocate from. For example, you might create a heap specifically for the linked list. The list's memory blocks and the data they contain would remain close together on fewer pages, reducing the amount of swapping required.
If you create a separate heap for each thread, you can allocate from them concurrently, eliminating both the waiting period and the overhead required to serialize access to the heap.
If you create a separate heap for that linked list, you can destroy it with a single call and free all the memory at once.
With multiple heaps, you can create a separate heap for each component, so if one damages the heap (for example, by using a freed pointer), the others can continue unaffected. You also know where to look to correct the problem.
You can create heaps of regular memory or shared memory, and you can have any number of heaps of any type. See Types of Memory for more information about the different types of memory for heaps. The only limit is the space available on your operating system (your machine's memory and swapper size, minus the memory required by other running applications).
IBM C and C++ Compilers provides heap-specific versions of the memory management functions, for example, umalloc and so on. Debug versions of all memory management functions are provided, including the heap-specific ones. IBM C and C++ Compilers also provides additional functions that you can use to create and manage your own heaps of memory, such as udefault.
Memory Management Functions
Types of Memory
Debugging Memory Heaps
Creating and Using a Fixed Size Heap
Creating and Using an Expandable Heap
Debugging Problems with Heap Memory
Changing the Default Heap Used in a Program
Example of Creating and Using a User Heap
Example of Creating and Using a Shared-Memory User Heap