The memory management functions defined by ANSI are calloc, malloc, realloc, and free. These regular functions allocate and free memory from the default run-time heap. VisualAge C++ has added another function, _heapmin, to return unused memory to the system. VisualAge C++ also provides different versions of each of these functions as extensions to the ANSI definition.
Both versions actually work the same way; they differ only in what heap they allocate from, and in whether they save information to help you debug memory problems. The memory allocated by all of these functions is suitably aligned for storing any type of object.
The run-time automatically pools objects from 1 to 512 bytes in size for the default runtime heap (_RUNTIME_HEAP), and aligns them on 8-byte boundaries. With this pooling objects are allocated and freed very quickly, and overhead is reduced. Any heap you create using _ucreate will not have a default pool; you must explicitly call _upool().
The following table summarizes the different versions of memory management functions, using malloc as an example of how the names of the functions change for each version.
| Regular Version | Debug Version | |
|---|---|---|
| Default Heap | malloc | _debug_malloc |
| User Heap | _umalloc | _debug_umalloc |
| _tmalloc | _debug_tmalloc |
To use these extensions, you must set
the language level to extended, either with the lang(level,
extended) compiler option or the #pragma langlvl(extended) directive. C++ does not
support #pragma langlvl or the lang(level) option.
![]()
Heap-Specific Functions
Tiled Memory Management
Functions
Tiled Debug Functions
![]()
Set Incorporation Options for Heap Debugging
Improve Memory Management
![]()
Debug Versions of Memory Management Functions
Differentiating Between Memory Management
Functions
