# Memory
[Core]

Collaboration diagram for Memory:

## Classes

class | Ogre::AlignedMemory
| Class to provide aligned memory allocate functionality. More...
class | Ogre::AllocatedObject< Alloc >
| Superclass for all objects that wish to use custom memory allocators when their new / delete operators are called. More...
class | Ogre::NedAllocImpl
| Non-templated utility class just to hide nedmalloc. More...
class | Ogre::NedAllocPolicy
| An allocation policy for use with AllocatedObject and STLAllocator. More...
class | Ogre::NedAlignedAllocPolicy< Alignment >
| An allocation policy for use with AllocatedObject and STLAllocator, which aligns memory at a given boundary (which should be a power of 2). More...
class | Ogre::NedPoolingImpl
| Non-templated utility class just to hide nedmalloc. More...
class | Ogre::NedPoolingPolicy
| An allocation policy for use with AllocatedObject and STLAllocator. More...
class | Ogre::NedPoolingAlignedPolicy< Alignment >
| An allocation policy for use with AllocatedObject and STLAllocator, which aligns memory at a given boundary (which should be a power of 2). More...
class | Ogre::StdAllocPolicy
| A "standard" allocation policy for use with AllocatedObject and STLAllocator. More...
class | Ogre::StdAlignedAllocPolicy< Alignment >
| A "standard" allocation policy for use with AllocatedObject and STLAllocator, which aligns memory at a given boundary (which should be a power of 2). More...
struct | Ogre::STLAllocatorBase< T >
| Wrapper class for operating as an STL container allocator. More...
struct | Ogre::STLAllocatorBase< const T >
class | Ogre::STLAllocator< T, AllocPolicy >

## Namespaces

namespace | Ogre

## Files

file | OgreMemoryAllocatorConfig.h

| This file configures Ogre's memory allocators.

## Defines

#define | OGRE_MALLOC(bytes, category) ::Ogre::CategorisedAllocPolicy<category>::allocateBytes(bytes)
| Allocate a block of raw memory, and indicate the category of usage.
#define | OGRE_ALLOC_T(T, count, category) static_cast<T*>(::Ogre::CategorisedAllocPolicy<category>::allocateBytes(sizeof(T)*(count)))
| Allocate a block of memory for a primitive type, and indicate the category of usage.
#define | OGRE_FREE(ptr, category) ::Ogre::CategorisedAllocPolicy<category>::deallocateBytes((void*)ptr)
| Free the memory allocated with OGRE_MALLOC or OGRE_ALLOC_T. Category is required to be restated to ensure the matching policy is used.
#define | OGRE_NEW_T(T, category) new (::Ogre::CategorisedAllocPolicy<category>::allocateBytes(sizeof(T))) T
| Allocate space for one primitive type, external type or non-virtual type with constructor parameters.
#define | OGRE_NEW_ARRAY_T(T, count, category) ::Ogre::constructN(static_cast<T*>(::Ogre::CategorisedAllocPolicy<category>::allocateBytes(sizeof(T)*(count))), count)
| Allocate a block of memory for 'count' primitive types - do not use for classes that inherit from AllocatedObject.
#define | OGRE_DELETE_T(ptr, T, category) if(ptr){(ptr)->~T(); ::Ogre::CategorisedAllocPolicy<category>::deallocateBytes((void*)ptr);}
| Free the memory allocated with OGRE_NEW_T. Category is required to be restated to ensure the matching policy is used.
#define | OGRE_DELETE_ARRAY_T(ptr, T, count, category) if(ptr){for (size_t b = 0; b < count; ++b) { (ptr)[b].~T();} ::Ogre::CategorisedAllocPolicy<category>::deallocateBytes((void*)ptr);}
| Free the memory allocated with OGRE_NEW_ARRAY_T. Category is required to be restated to ensure the matching policy is used, count and type to call destructor.
#define | OGRE_MALLOC_SIMD(bytes, category) ::Ogre::CategorisedAlignAllocPolicy<category>::allocateBytes(bytes)
| Allocate a block of raw memory aligned to SIMD boundaries, and indicate the category of usage.
#define | OGRE_MALLOC_ALIGN(bytes, category, align) ::Ogre::CategorisedAlignAllocPolicy<category, align>::allocateBytes(bytes)
| Allocate a block of raw memory aligned to user defined boundaries, and indicate the category of usage.
#define | OGRE_ALLOC_T_SIMD(T, count, category) static_cast<T*>(::Ogre::CategorisedAlignAllocPolicy<category>::allocateBytes(sizeof(T)*(count)))
| Allocate a block of memory for a primitive type aligned to SIMD boundaries, and indicate the category of usage.
#define | OGRE_ALLOC_T_ALIGN(T, count, category, align) static_cast<T*>(::Ogre::CategorisedAlignAllocPolicy<category, align>::allocateBytes(sizeof(T)*(count)))
| Allocate a block of memory for a primitive type aligned to user defined boundaries, and indicate the category of usage.
#define | OGRE_FREE_SIMD(ptr, category) ::Ogre::CategorisedAlignAllocPolicy<category>::deallocateBytes((void*)ptr)
| Free the memory allocated with either OGRE_MALLOC_SIMD or OGRE_ALLOC_T_SIMD. Category is required to be restated to ensure the matching policy is used.
#define | OGRE_FREE_ALIGN(ptr, category, align) ::Ogre::CategorisedAlignAllocPolicy<category, align>::deallocateBytes((void*)ptr)
| Free the memory allocated with either OGRE_MALLOC_ALIGN or OGRE_ALLOC_T_ALIGN. Category is required to be restated to ensure the matching policy is used.
#define | OGRE_NEW_T_SIMD(T, category) new (::Ogre::CategorisedAlignAllocPolicy<category>::allocateBytes(sizeof(T))) T
| Allocate space for one primitive type, external type or non-virtual type aligned to SIMD boundaries.
#define | OGRE_NEW_ARRAY_T_SIMD(T, count, category) ::Ogre::constructN(static_cast<T*>(::Ogre::CategorisedAlignAllocPolicy<category>::allocateBytes(sizeof(T)*(count))), count)
| Allocate a block of memory for 'count' primitive types aligned to SIMD boundaries - do not use for classes that inherit from AllocatedObject.
#define | OGRE_DELETE_T_SIMD(ptr, T, category) if(ptr){(ptr)->~T(); ::Ogre::CategorisedAlignAllocPolicy<category>::deallocateBytes((void*)ptr);}
| Free the memory allocated with OGRE_NEW_T_SIMD. Category is required to be restated to ensure the matching policy is used.
#define | OGRE_DELETE_ARRAY_T_SIMD(ptr, T, count, category) if(ptr){for (size_t b = 0; b < count; ++b) { (ptr)[b].~T();} ::Ogre::CategorisedAlignAllocPolicy<category>::deallocateBytes((void*)ptr);}
| Free the memory allocated with OGRE_NEW_ARRAY_T_SIMD. Category is required to be restated to ensure the matching policy is used, count and type to call destructor.
#define | OGRE_NEW_T_ALIGN(T, category, align) new (::Ogre::CategorisedAlignAllocPolicy<category, align>::allocateBytes(sizeof(T))) T
| Allocate space for one primitive type, external type or non-virtual type aligned to user defined boundaries.
#define | OGRE_NEW_ARRAY_T_ALIGN(T, count, category, align) ::Ogre::constructN(static_cast<T*>(::Ogre::CategorisedAlignAllocPolicy<category, align>::allocateBytes(sizeof(T)*(count))), count)
| Allocate a block of memory for 'count' primitive types aligned to user defined boundaries - do not use for classes that inherit from AllocatedObject.
#define | OGRE_DELETE_T_ALIGN(ptr, T, category, align) if(ptr){(ptr)->~T(); ::Ogre::CategorisedAlignAllocPolicy<category, align>::deallocateBytes((void*)ptr);}
| Free the memory allocated with OGRE_NEW_T_ALIGN. Category is required to be restated to ensure the matching policy is used.
#define | OGRE_DELETE_ARRAY_T_ALIGN(ptr, T, count, category, align) if(ptr){for (size_t _b = 0; _b < count; ++_b) { (ptr)[_b].~T();} ::Ogre::CategorisedAlignAllocPolicy<category, align>::deallocateBytes((void*)ptr);}
| Free the memory allocated with OGRE_NEW_ARRAY_T_ALIGN. Category is required to be restated to ensure the matching policy is used, count and type to call destructor.
#define | OGRE_NEW new
#define | OGRE_DELETE delete

## Enumerations

enum | Ogre::MemoryCategory { Ogre::MEMCATEGORY_GENERAL = 0, Ogre::MEMCATEGORY_GEOMETRY = 1, Ogre::MEMCATEGORY_ANIMATION = 2, Ogre::MEMCATEGORY_SCENE_CONTROL = 3, Ogre::MEMCATEGORY_SCENE_OBJECTS = 4, Ogre::MEMCATEGORY_RESOURCE = 5, Ogre::MEMCATEGORY_SCRIPTING = 6, Ogre::MEMCATEGORY_RENDERSYS = 7, Ogre::MEMCATEGORY_COUNT = 8 }
| A set of categories that indicate the purpose of a chunk of memory being allocated. More...

## Functions

template<typename T >
T * | Ogre::constructN (T *basePtr, size_t count)
| Utility function for constructing an array of objects with placement new, without using new[] (which allocates an undocumented amount of extra memory and so isn't appropriate for custom allocators).
template<typename T , typename T2 , typename P >
bool | Ogre::operator== (STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
| determine equality, can memory from another allocator be released by this allocator, (ISO C++)
template<typename T , typename P , typename OtherAllocator >
bool | Ogre::operator== (STLAllocator< T, P > const &, OtherAllocator const &)
| determine equality, can memory from another allocator be released by this allocator, (ISO C++)
template<typename T , typename T2 , typename P >
bool | Ogre::operator!= (STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
| determine equality, can memory from another allocator be released by this allocator, (ISO C++)
template<typename T , typename P , typename OtherAllocator >
bool | Ogre::operator!= (STLAllocator< T, P > const &, OtherAllocator const &)
| determine equality, can memory from another allocator be released by this allocator, (ISO C++)

## Define Documentation

#define OGRE_ALLOC_T | ( |  | T,
|  |  | count,
|  |  | category |
| ) |  |  | static_cast<T*>(::Ogre::CategorisedAllocPolicy<category>::allocateBytes(sizeof(T)*(count)))

Allocate a block of memory for a primitive type, and indicate the category of usage.

Definition at line 426 of file OgreMemoryAllocatorConfig.h.

Referenced by Ogre::AxisAlignedBox::getAllCorners(), Ogre::StreamSerialiser::readConverted(), Ogre::VertexCacheProfiler::VertexCacheProfiler(), and Ogre::StreamSerialiser::writeConverted().

#define OGRE_ALLOC_T_ALIGN | ( |  | T,
|  |  | count,
|  |  | category,
|  |  | align |
| ) |  |  | static_cast<T*>(::Ogre::CategorisedAlignAllocPolicy<category, align>::allocateBytes(sizeof(T)*(count)))

Allocate a block of memory for a primitive type aligned to user defined boundaries, and indicate the category of usage.

Definition at line 447 of file OgreMemoryAllocatorConfig.h.

#define OGRE_ALLOC_T_SIMD | ( |  | T,
|  |  | count,
|  |  | category |
| ) |  |  | static_cast<T*>(::Ogre::CategorisedAlignAllocPolicy<category>::allocateBytes(sizeof(T)*(count)))

Allocate a block of memory for a primitive type aligned to SIMD boundaries, and indicate the category of usage.

Definition at line 445 of file OgreMemoryAllocatorConfig.h.

#define OGRE_DELETE delete

Definition at line 472 of file OgreMemoryAllocatorConfig.h.

Referenced by Ogre::RenderQueueGroup::clear(), Ogre::deletePtr(), Ogre::SharedPtr< Skeleton >::destroy(), Ogre::ZipArchiveFactory::destroyInstance(), Ogre::SimplePageContentCollectionFactory::destroyInstance(), Ogre::UserObjectBindings::Attributes::~Attributes(), Ogre::DefaultHardwareBufferManager::~DefaultHardwareBufferManager(), Ogre::StaticGeometry::OptimisedSubMeshGeometry::~OptimisedSubMeshGeometry(), and Ogre::RenderQueueGroup::~RenderQueueGroup().

#define OGRE_DELETE_ARRAY_T | ( |  | ptr,
|  |  | T,
|  |  | count,
|  |  | category |
| ) |  |  | if(ptr){for (size_t b = 0; b < count; ++b) { (ptr)[b].~T();} ::Ogre::CategorisedAllocPolicy<category>::deallocateBytes((void*)ptr);}

Free the memory allocated with OGRE_NEW_ARRAY_T. Category is required to be restated to ensure the matching policy is used, count and type to call destructor.

Definition at line 437 of file OgreMemoryAllocatorConfig.h.

#define OGRE_DELETE_ARRAY_T_ALIGN | ( |  | ptr,
|  |  | T,
|  |  | count,
|  |  | category,
|  |  | align |
| ) |  |  | if(ptr){for (size_t _b = 0; _b < count; ++_b) { (ptr)[_b].~T();} ::Ogre::CategorisedAlignAllocPolicy<category, align>::deallocateBytes((void*)ptr);}

Free the memory allocated with OGRE_NEW_ARRAY_T_ALIGN. Category is required to be restated to ensure the matching policy is used, count and type to call destructor.

Definition at line 468 of file OgreMemoryAllocatorConfig.h.

#define OGRE_DELETE_ARRAY_T_SIMD | ( |  | ptr,
|  |  | T,
|  |  | count,
|  |  | category |
| ) |  |  | if(ptr){for (size_t b = 0; b < count; ++b) { (ptr)[b].~T();} ::Ogre::CategorisedAlignAllocPolicy<category>::deallocateBytes((void*)ptr);}

Free the memory allocated with OGRE_NEW_ARRAY_T_SIMD. Category is required to be restated to ensure the matching policy is used, count and type to call destructor.

Definition at line 460 of file OgreMemoryAllocatorConfig.h.

#define OGRE_DELETE_T | ( |  | ptr,
|  |  | T,
|  |  | category |
| ) |  |  | if(ptr){(ptr)->~T(); ::Ogre::CategorisedAllocPolicy<category>::deallocateBytes((void*)ptr);}

Free the memory allocated with OGRE_NEW_T. Category is required to be restated to ensure the matching policy is used.

Definition at line 435 of file OgreMemoryAllocatorConfig.h.

Referenced by Ogre::SharedPtr< Skeleton >::destroy(), and Ogre::Any::destroy().

#define OGRE_DELETE_T_ALIGN | ( |  | ptr,
|  |  | T,
|  |  | category,
|  |  | align |
| ) |  |  | if(ptr){(ptr)->~T(); ::Ogre::CategorisedAlignAllocPolicy<category, align>::deallocateBytes((void*)ptr);}

Free the memory allocated with OGRE_NEW_T_ALIGN. Category is required to be restated to ensure the matching policy is used.

Definition at line 466 of file OgreMemoryAllocatorConfig.h.

#define OGRE_DELETE_T_SIMD | ( |  | ptr,
|  |  | T,
|  |  | category |
| ) |  |  | if(ptr){(ptr)->~T(); ::Ogre::CategorisedAlignAllocPolicy<category>::deallocateBytes((void*)ptr);}

Free the memory allocated with OGRE_NEW_T_SIMD. Category is required to be restated to ensure the matching policy is used.

Definition at line 458 of file OgreMemoryAllocatorConfig.h.

#define OGRE_FREE | ( |  | ptr,
|  |  | category |
| ) |  |  | ::Ogre::CategorisedAllocPolicy<category>::deallocateBytes((void*)ptr)

Free the memory allocated with OGRE_MALLOC or OGRE_ALLOC_T. Category is required to be restated to ensure the matching policy is used.

Definition at line 428 of file OgreMemoryAllocatorConfig.h.

Referenced by Ogre::SharedPtr< Skeleton >::destroy(), Ogre::StreamSerialiser::readConverted(), Ogre::StreamSerialiser::writeConverted(), Ogre::AxisAlignedBox::~AxisAlignedBox(), and Ogre::VertexCacheProfiler::~VertexCacheProfiler().

#define OGRE_FREE_ALIGN | ( |  | ptr,
|  |  | category,
|  |  | align |
| ) |  |  | ::Ogre::CategorisedAlignAllocPolicy<category, align>::deallocateBytes((void*)ptr)

Free the memory allocated with either OGRE_MALLOC_ALIGN or OGRE_ALLOC_T_ALIGN. Category is required to be restated to ensure the matching policy is used.

Definition at line 451 of file OgreMemoryAllocatorConfig.h.

#define OGRE_FREE_SIMD | ( |  | ptr,
|  |  | category |
| ) |  |  | ::Ogre::CategorisedAlignAllocPolicy<category>::deallocateBytes((void*)ptr)

Free the memory allocated with either OGRE_MALLOC_SIMD or OGRE_ALLOC_T_SIMD. Category is required to be restated to ensure the matching policy is used.

Definition at line 449 of file OgreMemoryAllocatorConfig.h.

#define OGRE_MALLOC | ( |  | bytes,
|  |  | category |
| ) |  |  | ::Ogre::CategorisedAllocPolicy<category>::allocateBytes(bytes)

Allocate a block of raw memory, and indicate the category of usage.

Definition at line 424 of file OgreMemoryAllocatorConfig.h.

#define OGRE_MALLOC_ALIGN | ( |  | bytes,
|  |  | category,
|  |  | align |
| ) |  |  | ::Ogre::CategorisedAlignAllocPolicy<category, align>::allocateBytes(bytes)

Allocate a block of raw memory aligned to user defined boundaries, and indicate the category of usage.

Definition at line 443 of file OgreMemoryAllocatorConfig.h.

#define OGRE_MALLOC_SIMD | ( |  | bytes,
|  |  | category |
| ) |  |  | ::Ogre::CategorisedAlignAllocPolicy<category>::allocateBytes(bytes)

Allocate a block of raw memory aligned to SIMD boundaries, and indicate the category of usage.

Definition at line 441 of file OgreMemoryAllocatorConfig.h.

#define OGRE_NEW new

Definition at line 471 of file OgreMemoryAllocatorConfig.h.

Referenced by Ogre::RenderQueueGroup::addRenderable(), Ogre::RTShader::ShaderProgramWriterHLSLFactory::create(), Ogre::RTShader::ShaderProgramWriterGLSLFactory::create(), Ogre::SceneManager::createAutoParamDataSource(), Ogre::ZipArchiveFactory::createInstance(), Ogre::SimplePageContentCollectionFactory::createInstance(), and Ogre::RenderQueueGroup::merge().

#define OGRE_NEW_ARRAY_T | ( |  | T,
|  |  | count,
|  |  | category |
| ) |  |  | ::Ogre::constructN(static_cast<T*>(::Ogre::CategorisedAllocPolicy<category>::allocateBytes(sizeof(T)*(count))), count)

Allocate a block of memory for 'count' primitive types - do not use for classes that inherit from AllocatedObject.

Definition at line 433 of file OgreMemoryAllocatorConfig.h.

#define OGRE_NEW_ARRAY_T_ALIGN | ( |  | T,
|  |  | count,
|  |  | category,
|  |  | align |
| ) |  |  | ::Ogre::constructN(static_cast<T*>(::Ogre::CategorisedAlignAllocPolicy<category, align>::allocateBytes(sizeof(T)*(count))), count)

Allocate a block of memory for 'count' primitive types aligned to user defined boundaries - do not use for classes that inherit from AllocatedObject.

Definition at line 464 of file OgreMemoryAllocatorConfig.h.

#define OGRE_NEW_ARRAY_T_SIMD | ( |  | T,
|  |  | count,
|  |  | category |
| ) |  |  | ::Ogre::constructN(static_cast<T*>(::Ogre::CategorisedAlignAllocPolicy<category>::allocateBytes(sizeof(T)*(count))), count)

Allocate a block of memory for 'count' primitive types aligned to SIMD boundaries - do not use for classes that inherit from AllocatedObject.

Definition at line 456 of file OgreMemoryAllocatorConfig.h.

#define OGRE_NEW_T | ( |  | T,
|  |  | category |
| ) |  |  | new (::Ogre::CategorisedAllocPolicy<category>::allocateBytes(sizeof(T))) T

Allocate space for one primitive type, external type or non-virtual type with constructor parameters.

Definition at line 431 of file OgreMemoryAllocatorConfig.h.

Referenced by Ogre::AnyNumeric::numholder< ValueType >::add(), Ogre::AnyNumeric::AnyNumeric(), Ogre::SharedPtr< Skeleton >::bind(), Ogre::AnyNumeric::numholder< ValueType >::clone(), Ogre::Any::holder< ValueType >::clone(), Ogre::AnyNumeric::numholder< ValueType >::divide(), Ogre::AnyNumeric::numholder< ValueType >::multiply(), and Ogre::AnyNumeric::numholder< ValueType >::subtract().

#define OGRE_NEW_T_ALIGN | ( |  | T,
|  |  | category,
|  |  | align |
| ) |  |  | new (::Ogre::CategorisedAlignAllocPolicy<category, align>::allocateBytes(sizeof(T))) T

Allocate space for one primitive type, external type or non-virtual type aligned to user defined boundaries.

Definition at line 462 of file OgreMemoryAllocatorConfig.h.

#define OGRE_NEW_T_SIMD | ( |  | T,
|  |  | category |
| ) |  |  | new (::Ogre::CategorisedAlignAllocPolicy<category>::allocateBytes(sizeof(T))) T

Allocate space for one primitive type, external type or non-virtual type aligned to SIMD boundaries.

Definition at line 454 of file OgreMemoryAllocatorConfig.h.

## Enumeration Type Documentation

enum Ogre::MemoryCategory

A set of categories that indicate the purpose of a chunk of memory being allocated.

These categories will be provided at allocation time in order to allow the allocation policy to vary its behaviour if it wishes. This allows you to use a single policy but still have variant behaviour. The level of control it gives you is at a higher level than assigning different policies to different classes, but is the only control you have over general allocations that are primitive types.

Enumerator:

  MEMCATEGORY_GENERAL | General purpose.
  MEMCATEGORY_GEOMETRY | Geometry held in main memory.
  MEMCATEGORY_ANIMATION | Animation data like tracks, bone matrices.
  MEMCATEGORY_SCENE_CONTROL | Nodes, control data.
  MEMCATEGORY_SCENE_OBJECTS | Scene object instances.
  MEMCATEGORY_RESOURCE | Other resources.
  MEMCATEGORY_SCRIPTING | Scripting.
  MEMCATEGORY_RENDERSYS | Rendersystem structures.
  MEMCATEGORY_COUNT |

Definition at line 158 of file OgreMemoryAllocatorConfig.h.

## Function Documentation

template<typename T >

T* Ogre::constructN | ( | T * | basePtr,
|  | size_t | count |
| ) |  |  |

Utility function for constructing an array of objects with placement new, without using new[] (which allocates an undocumented amount of extra memory and so isn't appropriate for custom allocators).

Definition at line 344 of file OgreMemoryAllocatorConfig.h.

template<typename T , typename P , typename OtherAllocator >

bool Ogre::operator!= | ( | STLAllocator< T, P > const & | ,
|  | OtherAllocator const & |  |
| ) |  |  |

determine equality, can memory from another allocator be released by this allocator, (ISO C++)

Definition at line 205 of file OgreMemorySTLAllocator.h.

template<typename T , typename T2 , typename P >

bool Ogre::operator!= | ( | STLAllocator< T, P > const & | ,
|  | STLAllocator< T2, P > const & |  |
| ) |  |  |

determine equality, can memory from another allocator be released by this allocator, (ISO C++)

Definition at line 195 of file OgreMemorySTLAllocator.h.

template<typename T , typename P , typename OtherAllocator >

bool Ogre::operator== | ( | STLAllocator< T, P > const & | ,
|  | OtherAllocator const & |  |
| ) |  |  |

determine equality, can memory from another allocator be released by this allocator, (ISO C++)

Definition at line 187 of file OgreMemorySTLAllocator.h.

template<typename T , typename T2 , typename P >

bool Ogre::operator== | ( | STLAllocator< T, P > const & | ,
|  | STLAllocator< T2, P > const & |  |
| ) |  |  |

determine equality, can memory from another allocator be released by this allocator, (ISO C++)

Definition at line 177 of file OgreMemorySTLAllocator.h.

Referenced by Ogre::Quaternion::operator!=(), and Ogre::Matrix3::operator!=().

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:52