To allocate and release memory in your C functions, the API provides utility methods, such as the sqlmr_alloc, sqlmr_release and other methods of Memory.h. In addition, many of the datatype objects such as String provide more specialized memory utility functions. See Datatypes in the C API.