Orxonox
0.0.5 Codename: Arcturus
|
Declaration of SmallObjectAllocator. More...
Go to the source code of this file.
Classes | |
class | orxonox::SmallObjectAllocator |
This class is used to allocate and free small objects (usually not polymorphic). More... | |
struct | orxonox::SmallObjectAllocator::Chunk |
The memory chunk is at the same time an element of a single linked list. More... | |
Namespaces | |
orxonox | |
Die Wagnis Klasse hat die folgenden Aufgaben: | |
Declaration of SmallObjectAllocator.
The default implementations of new and delete are designed to work with objects of arbitrary size. They are thus not optimal for small objects. SmallObjectAllocator allocates a large memory block and divides it into small chunks. These chunks are returned by the function alloc() and can be used to create a new object using the placement new operator. Instead of delete, the function free() is used to give the memory back to SmallObjectAllocator.
Example:
Important: You have to call the destructor of the object manually, because this is not automatically done by the allocator nor free().