Home | Previous Page | Next Page   Design Decisions > Storing Data in Shared Memory >

Functions That Allocate and Free Memory

The DataBlade API provides two categories of memory-allocation functions:

For either unnamed or named memory, you can specify a duration that reserves the memory for access method use beyond the life of a particular purpose function.

For most purposes, UDRs, including access methods, can allocate shared memory with the public DataBlade API memory-management functions, mi_alloc(), mi_dalloc(), or mi_zalloc(). UDRs share access to memory that a public function allocates with the pointer that the allocation function returns. For an example that allocates memory and stores a pointer, refer to Persistent User Data. The public mi_free() function frees the memory that a public function allocates.

The memory that you allocate with public functions is available only to UDRs that execute during a single-thread table operation. Access-method UDRs might execute across multiple threads to manipulate multiple fragments or span multiple queries. UDRs that execute in multiple threads can share named memory.

The semipublic DataBlade API mi_named_alloc() or mi_named_zalloc() memory-management functions allocate named memory, the mi_named_get() function retrieves named memory, and the mi_named_free() function releases the named memory. Related semipublic functions provide for locking on named memory.

Warning:
Do not call malloc() because the memory that malloc() allocates disappears after a virtual processor (VP) switch. The access method might not properly deallocate memory that malloc() provides, especially during exception handling.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]