Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::OrderedChunkAllocator Class Reference

Special "ordered" memory allocator. More...

#include <mitsuba/render/gkdtree.h>

Public Member Functions

 OrderedChunkAllocator (size_t minAllocation=512 *1024)
 
 ~OrderedChunkAllocator ()
 
void cleanup ()
 Release all memory used by the allocator. More...
 
void merge (const OrderedChunkAllocator &other)
 Merge the chunks of another allocator into this one. More...
 
void forget ()
 Forget about all chunks without actually freeing them. This is useful when the chunks have been merged into another allocator. More...
 
template<typename T >
T *__restrict allocate (size_t size)
 Request a block of memory from the allocator. More...
 
template<typename T >
void release (T *ptr)
 
template<typename T >
void shrinkAllocation (T *ptr, size_t newSize)
 Shrink the size of the last allocated chunk. More...
 
size_t getChunkCount () const
 
size_t size () const
 Return the total amount of chunk memory in bytes. More...
 
size_t used () const
 Return the total amount of used memory in bytes. More...
 
std::string toString () const
 Return a string representation of the chunks. More...
 

Detailed Description

Special "ordered" memory allocator.

During kd-tree construction, large amounts of memory are required to temporarily hold index and edge event lists. When not implemented properly, these allocations can become a critical bottleneck. The class OrderedChunkAllocator provides a specialized memory allocator, which reserves memory in chunks of at least 128KiB. An important assumption made by the allocator is that memory will be released in the exact same order, in which it was previously allocated. This makes it possible to create an implementation with a very low memory overhead. Note that no locking is done, hence each thread will need its own allocator.

Author
Wenzel Jakob

Constructor & Destructor Documentation

mitsuba::OrderedChunkAllocator::OrderedChunkAllocator ( size_t  minAllocation = 512*1024)
inline
mitsuba::OrderedChunkAllocator::~OrderedChunkAllocator ( )
inline

Member Function Documentation

template<typename T >
T* __restrict mitsuba::OrderedChunkAllocator::allocate ( size_t  size)
inline

Request a block of memory from the allocator.

Walks through the list of chunks to find one with enough free memory. If no chunk could be found, a new one is created.

void mitsuba::OrderedChunkAllocator::cleanup ( )
inline

Release all memory used by the allocator.

void mitsuba::OrderedChunkAllocator::forget ( )
inline

Forget about all chunks without actually freeing them. This is useful when the chunks have been merged into another allocator.

size_t mitsuba::OrderedChunkAllocator::getChunkCount ( ) const
inline
void mitsuba::OrderedChunkAllocator::merge ( const OrderedChunkAllocator other)
inline

Merge the chunks of another allocator into this one.

template<typename T >
void mitsuba::OrderedChunkAllocator::release ( T *  ptr)
inline
template<typename T >
void mitsuba::OrderedChunkAllocator::shrinkAllocation ( T *  ptr,
size_t  newSize 
)
inline

Shrink the size of the last allocated chunk.

size_t mitsuba::OrderedChunkAllocator::size ( ) const
inline

Return the total amount of chunk memory in bytes.

std::string mitsuba::OrderedChunkAllocator::toString ( ) const
inline

Return a string representation of the chunks.

size_t mitsuba::OrderedChunkAllocator::used ( ) const
inline

Return the total amount of used memory in bytes.


The documentation for this class was generated from the following file: