Deallocate named memory

To conserve resources, use the mi_named_free() function to explicitly deallocate the named memory once your DataBlade® API module no longer needs it. The mi_named_free() function is the destructor function for named memory.

The database server automatically reclaims the named memory that mi_named_alloc() and mi_named_zalloc() allocate. The memory duration of the named memory determines when the database server marks the memory for deallocation. Named memory remains valid until either of the following events occurs:
  • The mi_named_free() function frees the memory.
  • The memory duration expires.
Keep the following restrictions in mind about memory deallocation of named memory:
  • Do not free memory until you are finished accessing the memory.
  • Do not free memory that is still locked.
  • Do not use mi_named_free() to deallocate memory that you have not explicitly allocated with mi_named_alloc() or mi_named_zalloc().
  • Do not attempt to free named memory after its memory duration has expired.
  • Reuse memory whenever possible. Do not repeat calls to allocation functions if you can reuse the memory for another task.

The mi_named_free() function cannot free a named-memory block that is currently locked by another owner. If a UDR with another owner has a lock on the requested memory block, mi_named_free() marks the block as “deallocation pending" but does not actually free the memory. A subsequent call to mi_named_get() would return the MI_NO_SUCH_NAME return value for this named-memory block. After the UDR with another owner has explicitly unlocked the memory block with mi_unlock_memory(), a “deallocation pending" memory block is automatically freed. A subsequent call to mi_named_get() from this other UDR would return the MI_NO_SUCH_NAME return value for this named-memory block.