Result-Buffer Memory Management

The main difference between result-buffer lists and comparable AutoLISP result lists is that an ObjectARX application must explicitly manage the lists that it creates and uses. Whether an application creates a list or has one passed to it, it is the application's responsibility to release the result buffers that it allocates. ObjectARX has no automatic garbage collection as AutoLISP does. The application must call the library function acutRelRb() to release dynamically allocated result buffers when the application is finished with them.

The acutRelRb() function releases the entire list that follows the specified result buffer, including the specified (head) buffer itself and any string values that the buffers in the list point to. To release a string without removing the buffer itself, or to release a string belonging to a static result buffer, the application must call the standard C library function free().

Danger: Do not write data to a dynamic location that hasn't been allocated with direct calls to malloc() or with the ObjectARX library (including acutNewRb()). This can corrupt data in memory. Conversely, calling free() or acutRelRb() to release data that was allocated statically—in a static or automatic variable declaration—also can corrupt memory. Inserting a statically allocated variable, such as a string, into a result-buffer list causes your program to fail when you release the list with acutRelRb().

Sample calls to acutRelRb() appear in several of the code examples in the following sections.