|
FEDEM Model Database
R8.0
Source code of the FEDEM model database
|
Class to streamline efficient memory allocation. More...
#include <FFaMemPool.H>
Public Member Functions | |
| FFaMemPool (size_t objSize, FFaMemPoolMgr *mgr=NULL, int blockSize=512) | |
| The constructor intializes the data members. More... | |
| FFaMemPool (const FFaMemPool &mempool) | |
| Copy constructor. More... | |
| ~FFaMemPool () | |
| The destructor releases all heap-allocated memory. More... | |
| void * | doNew (size_t objSize) |
| Allocates a chunk of memory of size objSize. More... | |
| void | doDelete (void *p, size_t objSize) |
| Deallocates a memory chunk. More... | |
| void | freePool (bool release=false) |
| Releases all heap-allocated memory in this pool. More... | |
| void | freePartOfPool (void *objPtrAsId) |
| Releases heap-allocated memory associated with specified object. More... | |
| void | usePartOfPool (void *objPtrAsId) |
| Finds or creates a memory pool for specified object. More... | |
| void | useDefaultPartOfPool () |
| Resets the current memory pool the default instance. More... | |
Class to streamline efficient memory allocation.
This class is used to help the programmer to reimplement the operators new and delete for small classes that will be instantiated a lot of times. To use, simply make a static member of FFaMemPool in your class, reimplement the operators new and delete in that class by forwarding the calls to FFaMemPool::doNew() and FFaMemPool::doDelete(), respectively:
In the implementation file :
|
explicit |
The constructor intializes the data members.
| FFaMemPool::FFaMemPool | ( | const FFaMemPool & | mempool | ) |
Copy constructor.
| FFaMemPool::~FFaMemPool | ( | ) |
The destructor releases all heap-allocated memory.
| void FFaMemPool::doDelete | ( | void * | p, |
| size_t | objSize | ||
| ) |
Deallocates a memory chunk.
| void * FFaMemPool::doNew | ( | size_t | objSize | ) |
Allocates a chunk of memory of size objSize.
| void FFaMemPool::freePartOfPool | ( | void * | objPtrAsId | ) |
Releases heap-allocated memory associated with specified object.
| void FFaMemPool::freePool | ( | bool | release = false | ) |
Releases all heap-allocated memory in this pool.
|
inline |
Resets the current memory pool the default instance.
| void FFaMemPool::usePartOfPool | ( | void * | objPtrAsId | ) |
Finds or creates a memory pool for specified object.