122 static constexpr
size_t kBlockAlignment =
alignof(std::max_align_t);
129 size_t blocks_per_chunk{0};
143 bool prealloc{
false};
155 size_t blocks_per_chunk{0};
156 size_t block_size{0};
157 uint64_t hit_count{0};
158 uint64_t deallocate_count{0};
159 uint64_t in_use_blocks{0};
160 uint64_t chunk_count{0};
161 uint64_t upstream_alloc_count{0};
162 uint64_t upstream_alloc_bytes{0};
173 uint64_t alloc_count{0};
174 uint64_t alloc_bytes{0};
175 uint64_t dealloc_count{0};
237 [[nodiscard]]
void*
allocate(
size_t bytes,
size_t alignment = kBlockAlignment) noexcept;
246 void deallocate(
void* p,
size_t bytes,
size_t alignment = kBlockAlignment) noexcept;
264 [[nodiscard]] std::vector<
TierStats> get_stats() const noexcept;
284 void reset_stats() noexcept;
296 void clear() noexcept;
304 void trim() noexcept;
321 [[nodiscard]] static
Config get_default_config();
337 static
MemoryPool& global_instance(
bool use_env_level = true);
340 size_t find_tier(
size_t bytes) const noexcept;
343 std::unique_ptr<Impl> impl_;
Per-tier free-list pool with runtime statistics and oversized passthrough.
Definition: memory_pool.h:113
MemoryPool(const Config &config)
Constructs a tiered pool with an explicit configuration.
void * allocate(size_t bytes, size_t alignment=kBlockAlignment) noexcept
Allocates bytes of memory from the appropriate tier.
size_t get_tier_count() const noexcept
Returns the number of live managed tiers.
MemoryPool()
Constructs an empty pool in bypass mode.
void deallocate(void *p, size_t bytes, size_t alignment=kBlockAlignment) noexcept
Returns a block previously allocated through allocate to the pool.
~MemoryPool()
Releases every owned chunk unconditionally.
MemoryPool(int level, bool prealloc=false)
Constructs a tiered pool using the built-in pyramid for level.
Cross-platform macros for visibility, branch hints, copy prevention, singletons and string helpers.
#define VLINK_EXPORT
Definition: macros.h:81
#define VLINK_DISALLOW_COPY_AND_ASSIGN(classname)
Deletes the copy constructor and copy-assignment operator of classname.
Definition: macros.h:174
Constructor configuration grouping the tier list and the preallocation toggle.
Definition: memory_pool.h:141
std::vector< Tier > tiers
Tier descriptors; empty or all-sentinel selects bypass mode.
Definition: memory_pool.h:142
Statistics for allocations that bypass the tier free lists.
Definition: memory_pool.h:172
Per-tier runtime statistics snapshot.
Definition: memory_pool.h:153
Descriptor for one size class.
Definition: memory_pool.h:127