Memory Management Functions

Memory management functions handle the allocation and deallocation of dynamic memory. These functions form an abstraction layer above the standard C memory management functions malloc, free, and realloc. This block of functions can be replaced by the user with custom code to implement a different memory management scheme. For example, an embedded system application might want to use a fixed-sized static block from which to allocate.

The built-in memory management logic implements a nibble-allocation memory management algorithm that provides superior performance to calling malloc and free directly. This algorithm causes memory blocks to be allocated up front in larger sizes and then subsequently split up when future allocation requests are received. These blocks can be reset and reused in applications that are constantly allocating and freeing memory (for example, a decoder that constantly reads and decodes XML messages in a long running loop).

The key memory management functions that a user might use are the following:

Note that these memory management functions are only used in the generation of C code, not C++ (although a user can use them in a C++ application). For C++, the built-in new and delete operators are used to ensure constructors and destructors are properly executed.

For a full description of these and other memory management functions, see the XBinder C/C++ Runtime Reference Manual.