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... | |
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.
|
inline |
|
inline |
|
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.
|
inline |
Release all memory used by the allocator.
|
inline |
Forget about all chunks without actually freeing them. This is useful when the chunks have been merged into another allocator.
|
inline |
|
inline |
Merge the chunks of another allocator into this one.
|
inline |
|
inline |
Shrink the size of the last allocated chunk.
|
inline |
Return the total amount of chunk memory in bytes.
|
inline |
Return a string representation of the chunks.
|
inline |
Return the total amount of used memory in bytes.