5#ifndef BITCOIN_MEMUSAGE_H
6#define BITCOIN_MEMUSAGE_H
19#include <unordered_map>
20#include <unordered_set>
40template<
typename X>
static inline size_t DynamicUsage(X *
const &v) {
return 0; }
41template<
typename X>
static inline size_t DynamicUsage(
const X *
const &v) {
return 0; }
56 }
else if (
sizeof(
void*) == 8) {
57 return ((alloc + 31) >> 4) << 4;
58 }
else if (
sizeof(
void*) == 4) {
59 return ((alloc + 15) >> 3) << 3;
93template<
unsigned int N,
typename X,
typename S,
typename D>
99template<
typename X,
typename Y>
105template<
typename X,
typename Y>
111template<
typename X,
typename Y,
typename Z>
117template<
typename X,
typename Y,
typename Z>
125template<
typename X,
typename Y>
131template<
typename X,
typename Y>
174template<
typename X,
typename Y>
180template<
typename X,
typename Y,
typename Z>
186template <
class Key,
class T,
class Hash,
class Pred, std::
size_t MAX_BLOCK_SIZE_BYTES, std::
size_t ALIGN_BYTES>
192 MAX_BLOCK_SIZE_BYTES,
195 auto* pool_resource =
m.get_allocator().resource();
199 size_t estimated_list_node_size =
MallocUsage(
sizeof(
void*) * 3);
200 size_t usage_resource = estimated_list_node_size * pool_resource->NumAllocatedChunks();
201 size_t usage_chunks =
MallocUsage(pool_resource->ChunkSizeBytes()) * pool_resource->NumAllocatedChunks();
202 return usage_resource + usage_chunks +
MallocUsage(
sizeof(
void*) *
m.bucket_count());
Forwards all allocations/deallocations to the PoolResource.
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without h...
size_t allocated_memory() const
uint256 Hash(const T &in1)
Compute the 256-bit hash of an object.
#define T(expected, seed, data)
static size_t DynamicUsage(const int8_t &v)
Dynamic memory usage for built-in types is zero.
static size_t IncrementalDynamicUsage(const std::set< X, Y > &s)
static size_t MallocUsage(size_t alloc)
Compute the total memory used by allocating alloc bytes.