quick start:g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_system.a #include <MemoryManager.h> MemoryManager(); void* get(); boolean release(voidp ptr);
description:// declare MemoryManager object in TRACK mode // MemoryManager mgr_t(sizeof(float), 1024, TRACK); // declare local variable // long size = 100; // allocate a chunk of contiguous memory // float** ptrs_t = (float**)mgr_t.getBlock(size * sizeof(float*)); // release that chunk of contiguous memory // mgr_t.releaseBlock(ptrs_t);
static const SysString CLASS_NAME = L"MemoryManager";
static const long ALLOC_SIZE = 32;
enum MODE {OPTIMIZE = 0, TRACK, DEF_MODE = OPTIMIZE};
static const long DEF_GROW_SIZE = MemoryManagerBase::DEF_GROW_SIZE;
static const long ERR = 1200;
static const long ERR_NOTFND = 1201;
static const long ERR_NOTEMP = 1202;
MemoryManagerBase* virtual_mgr_d;
static const SysString& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean debug(const unichar* message);
static boolean setDebug(Integral::DEBUG level_a);
~MemoryManager();
these methods are omitted because moving memory between MemoryManager objects is nonsensical
these methods are omitted because moving memory between MemoryManager objects is nonsensical
these methods are omitted because MemoryManager can not write itself to an sof file
these methods are omitted because they do not make sense for MemoryManager objects
new and delete are omitted because memory for MemoryManager objects is not managed by the MemoryManager class. clear and cleanUp methods are omitted so the user is not allowed to be careless with memory while expecting cleanUp to mask the effects.
MemoryManager(long elem_size, long grow_size = DEF_GROW_SIZE);
MemoryManager(long elem_size, const SysString& name, long grow_size = DEF_GROW_SIZE);
void* get(); (TRACK OPTIMIZE)
boolean release(void* ptr); (TRACK OPTIMIZE)
void* getBlock(long size); (TRACK OPTIMIZE)
boolean releaseBlock(void* ptr); (TRACK OPTIMIZE)
boolean setGrow(long size); (TRACK OPTIMIZE)
boolean setAllocGrow(long size); (TRACK OPTIMIZE)
static boolean reallocateBlock(void*** ptr, long& current_size,long grow_size = DEF_GROW_SIZE); (TRACK OPTIMIZE)
static boolean memset(void* ptr, long val, long size);
static boolean memcpy(void* dst, const void* src, long size);
static long memcmp(const void* s1, const void* s2, long size);
static void* newStatic(long nbytes);
static boolean deleteStatic(void* ptr);
static boolean releaseStatics();
MemoryManager();
MemoryManager(const MemoryManager& arg);
boolean grow();(TRACK OPTIMIZE)
boolean countNodes(long& used, long& free) const;(TRACK OPTIMIZE)
boolean setMode(MODE mode, long elem_size, long grow_size);examples:
// declare MemoryManager object // MemoryManager mgr_t(sizeof(float), 1024, TRACK); // allocate memory / for (long i = 0; i < 100; i++) { ptrs_t[i] = (float*)mgr_t.get(); } // release memory // for (long i = 0; i < 100; i++) { mgr_t.release(ptrs_t[i]); }
// declare MemoryManager object // MemoryManager mgr_t(sizeof(float), 1024, TRACK); // allocate a chunk of memory // long size = 1000; float** ptrs_t = (float**)mgr_t.getBlock(size * sizeof(float*)); // release a chunk of memory // mgr_t.releaseBlock(ptrs_t);
isip111_[1]: ident DoubleLinkedListDiagnose.exe DoubleLinkedListDiagnose.exe: $MemoryManager: TRACK $The string will either be TRACK or OPTIMIZE.