OGRE
2.2.4
Object-Oriented Graphics Rendering Engine
|
Abstract memory manager for managing large chunks of contiguous memory, optimized for SoA (Structure of Arrays) implementations. More...
#include <OgreArrayMemoryManager.h>
Classes | |
class | RebaseListener |
When mUsedMemory >= mMaxMemory (that is, we've exhausted all our preallocated memory) ArrayMemoryManager will proceed to reallocate all memory. More... | |
Public Types | |
typedef std::vector< ptrdiff_t > | PtrdiffVec |
Public Member Functions | |
ArrayMemoryManager (size_t const *elementsMemSize, CleanupRoutines const *initRoutines, CleanupRoutines const *cleanupRoutines, size_t numElementsSize, uint16 depthLevel, size_t hintMaxNodes, size_t cleanupThreshold=100, size_t maxHardLimit=MAX_MEMORY_SLOTS, RebaseListener *rebaseListener=0) | |
Constructor. More... | |
void | defragment (void) |
Triggers on demand a defragmentation of the pools, so that all slots become contiguous in memory. More... | |
void | destroy () |
Destroys the memory ptrs. More... | |
size_t | getAllMemory () const |
Gets all memory reserved for this manager. More... | |
size_t | getFreeMemory () const |
Gets available memory in bytes. More... | |
size_t | getNumUsedSlotsIncludingFragmented () const |
Returns mUsedMemory. More... | |
size_t | getUsedMemory () const |
Gets used memory in bytes (not including waste) More... | |
size_t | getWastedMemory () const |
Gets wasted memory (perform a cleanup to fix) More... | |
void | initialize () |
Initializes mMemoryPools. More... | |
void | shrinkToFit (void) |
Defragments memory, then reallocates a smaller pool that tightly fits the current number of objects. More... | |
Static Public Attributes | |
static const size_t | MAX_MEMORY_SLOTS |
Abstract memory manager for managing large chunks of contiguous memory, optimized for SoA (Structure of Arrays) implementations.
typedef std::vector<ptrdiff_t> Ogre::ArrayMemoryManager::PtrdiffVec |
Ogre::ArrayMemoryManager::ArrayMemoryManager | ( | size_t const * | elementsMemSize, |
CleanupRoutines const * | initRoutines, | ||
CleanupRoutines const * | cleanupRoutines, | ||
size_t | numElementsSize, | ||
uint16 | depthLevel, | ||
size_t | hintMaxNodes, | ||
size_t | cleanupThreshold = 100 , |
||
size_t | maxHardLimit = MAX_MEMORY_SLOTS , |
||
RebaseListener * | rebaseListener = 0 |
||
) |
Constructor.
intialize. destroy.
elementsMemSize | Array containing the size in bytes of each element type (i.e. NodeElementsMemSize) |
initRoutines | Array containing the cleanup function that will be called when default initializing memory. Unlike cleanupRoutines, just leave the function pointer null if all you want is just to initialize to 0. |
cleanupRoutines | Array containing the cleanup function that will be called when performing cleanups. Many pointers can use the flatCleaner and is the fastest. However Array variables (i.e. ArrayVector3) have a layout where flatCleaner won't work correctly because the data is interleaved (rather than flat). |
numElementsSize | Number of entries in elementsMemSize |
depthLevel | Value only used to pass to the listener. Identifies to which hierarchy depth level this memory manager belongs to. |
hintMaxNodes | Hint on how many SceneNodes we'll be creating. |
cleanupThreshold | The threshold at which a cleanup is triggered after too many nodes have been destroyed in a non-LIFO order or without being created again. -1 to disable cleanups. |
maxHardLimit | Maximum amount of SceneNodes. The manager is not allowed to grow and consume more memory past that limit. MAX_MEMORY_SLOTS for no limit. This is useful when target architecture has much less memory than the dev machine. |
rebaseListener | The listener to be called when cleaning up or growing the memory pool. If null, cleanupThreshold is set to -1 & maxHardLimit will be set to hintMaxNodes |
void Ogre::ArrayMemoryManager::defragment | ( | void | ) |
Triggers on demand a defragmentation of the pools, so that all slots become contiguous in memory.
ArrayMemoryManager::destroySlot already does this when the number of fragmented slots reaches mCleanupThreshold
void Ogre::ArrayMemoryManager::destroy | ( | ) |
Destroys the memory ptrs.
initialize
size_t Ogre::ArrayMemoryManager::getAllMemory | ( | ) | const |
Gets all memory reserved for this manager.
size_t Ogre::ArrayMemoryManager::getFreeMemory | ( | ) | const |
Gets available memory in bytes.
size_t Ogre::ArrayMemoryManager::getNumUsedSlotsIncludingFragmented | ( | ) | const |
Returns mUsedMemory.
When ARRAY_PACKED_REALS = 4, and 4 objects have been created but the 2nd one has been deleted, getNumUsedSlotsIncludingFragmented will still return 4 until the 4th object is removed or a cleanup is performed
size_t Ogre::ArrayMemoryManager::getUsedMemory | ( | ) | const |
Gets used memory in bytes (not including waste)
size_t Ogre::ArrayMemoryManager::getWastedMemory | ( | ) | const |
Gets wasted memory (perform a cleanup to fix)
void Ogre::ArrayMemoryManager::initialize | ( | ) |
Initializes mMemoryPools.
Once it has been called, destroy() must be called. destroy
void Ogre::ArrayMemoryManager::shrinkToFit | ( | void | ) |
Defragments memory, then reallocates a smaller pool that tightly fits the current number of objects.
Useful when you know you won't be creating more slots and you need to reclaim memory.
|
static |