1#ifndef YAZE_APP_GFX_MEMORY_POOL_H
2#define YAZE_APP_GFX_MEMORY_POOL_H
6#include <unordered_map>
139 template <
typename U>
148 template <
typename U>
153 template <
typename U>
High-performance memory pool allocator for graphics data.
size_t total_allocated_bytes_
static constexpr size_t kSmallBlockSize
void Deallocate(void *ptr)
Deallocate memory block.
size_t GetPoolIndex(size_t size) const
static constexpr size_t kHugeBlockSize
void * Allocate(size_t size)
Allocate memory block of specified size.
void * AllocateAligned(size_t size, size_t alignment)
Allocate memory block aligned to specified boundary.
static constexpr size_t kLargeBlockSize
std::vector< MemoryBlock > medium_blocks_
static constexpr size_t kMediumBlockSize
std::unordered_map< void *, MemoryBlock * > allocated_blocks_
std::vector< MemoryBlock > huge_blocks_
std::vector< MemoryBlock > small_blocks_
MemoryBlock * FindFreeBlock(size_t size)
void Clear()
Clear all allocated blocks (for cleanup)
std::pair< size_t, size_t > GetAllocationStats() const
Get allocation statistics.
std::pair< size_t, size_t > GetMemoryStats() const
Get memory usage statistics.
static MemoryPool & Get()
size_t total_allocations_
size_t total_deallocations_
void InitializeBlockPool(std::vector< MemoryBlock > &pool, size_t block_size, size_t count)
std::vector< MemoryBlock > large_blocks_
RAII wrapper for memory pool allocations.
void deallocate(pointer p, size_type)
pointer allocate(size_type n)
const T & const_reference
bool operator!=(const PoolAllocator< U > &) const
PoolAllocator(const PoolAllocator< U > &)
std::ptrdiff_t difference_type
bool operator==(const PoolAllocator< U > &) const
Main namespace for the application.
MemoryBlock(void *d, size_t s, size_t a=0)