Memory Management: 3.3 Using Global Memory: Freeing Memory

Up: GEOS SDK TechDocs | Up | Prev: 3.2 Requesting Memory | Next: 3.4 Accessing Data in a Block
MemFree()

When you are done using a block, you should free it. Every block takes up space in the global handle table; if blocks are not freed, the handle table may fill up, causing a system error. Furthermore, non-swapable, non-discardable blocks take up space in the global heap until they are freed.

To free a block, call MemFree() and pass the handle of the block to be freed. The block will be freed even if it is locked. Therefore, if the block can be used by other threads, you should make sure no other thread has locked the block before you free it.

You can also set a reference count for a block. When a block's reference count drops to zero, the memory manager will automatically free it. This is useful if several threads will be accessing the same block. For more information, see The Reference Count .

When a geode exits, all blocks owned by it are automatically freed.


Up: GEOS SDK TechDocs | Up | Prev: 3.2 Requesting Memory | Next: 3.4 Accessing Data in a Block