5#ifndef BITCOIN_MEMUSAGE_H
6#define BITCOIN_MEMUSAGE_H
17#include <unordered_map>
18#include <unordered_set>
57template <
typename X>
static inline size_t DynamicUsage(X *
const &v) {
60template <
typename X>
static inline size_t DynamicUsage(
const X *
const &v) {
77 }
else if (
sizeof(
void *) == 8) {
78 return ((alloc + 31) >> 4) << 4;
79 }
else if (
sizeof(
void *) == 4) {
80 return ((alloc + 15) >> 3) << 3;
112template <
unsigned int N,
typename X,
typename S,
typename D>
117template <
typename X,
typename Y>
122template <
typename X,
typename Y>
127template <
typename X,
typename Y,
typename Z>
132template <
typename X,
typename Y,
typename Z>
139template <
typename X,
typename Y>
145template <
typename X,
typename Y>
171template <
typename X,
typename Y>
177template <
typename X,
typename Y,
typename Z>
178static inline size_t DynamicUsage(
const std::unordered_map<X, Y, Z> &m) {
184template <
class Key,
class T,
class Hash,
class Pred,
187 const std::unordered_map<Key, T,
Hash,
Pred,
Forwards all allocations/deallocations to the PoolResource.
Map whose keys are pointers, but are compared by their dereferenced values.
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.
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.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
void * class_type
Various platforms use different sized counters here.