This function defragments the object (removes all unused memory "holes" for dynamic fields).
MCO_RET classname_pack( /*IN*/ classname * handle, /*OUT*/ uint4 * pages_released);
handle | The address of a variable of type |
pages_released |
A pointer to uint4 that receives the number of pages released back to the free page pool |
The
_pack()
method is generated for all classes with dynamic fields (vectors and/or strings). When a dynamic object is re-allocated at runtime, it could get fragmented. For example if the vector size went from 2 to 3, the space allocated for the original elements might (but not necessarily will ) get temporarily lost. Note that this does not create a memory leak, but object fragmentation (when the object is deleted, all object pages are returned back to the memory pool).The
_pack()
method defragments the object and removes all unused "holes" created at runtime by the_erase()
method so that the space occupied by the deleted, and now inaccessible, element is returned to the free database memory pool. This API is often used by applications to put together application-specific object-based "defragmentor" or a "garbage collector". System-wide garbage collectors usually require extra CPU cycles to keep the database free of fragmentation or take measures not to fragment dynamic objects at all. With the_pack
() API eXtremeDB provides a way to build an application-specific “defragmentor”. The application controls whether and when the method is called and the defragmentation takes place.