Functions that allocate and free memory
The DataBlade API provides public functions and semipublic functions for memory allocation.
- Public functions
- Allocate memory that is local to one database server thread.
- Semipublic functions
- Allocate named, global memory that multiple threads might share.
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, see 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 index 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.