5#ifndef BITCOIN_MEMUSAGE_H 
    6#define BITCOIN_MEMUSAGE_H 
   20#include <unordered_map> 
   21#include <unordered_set> 
   41template<
typename X> 
static inline size_t DynamicUsage(
X * 
const &v) { 
return 0; }
 
   42template<
typename X> 
static inline size_t DynamicUsage(
const X * 
const &v) { 
return 0; }
 
   57    } 
else if (
sizeof(
void*) == 8) {
 
   58        return ((alloc + 31) >> 4) << 4;
 
   59    } 
else if (
sizeof(
void*) == 4) {
 
   60        return ((alloc + 15) >> 3) << 3;
 
   88template<
typename T, 
typename Allocator>
 
   89static inline size_t DynamicUsage(
const std::vector<T, Allocator>& v)
 
   96    const char* s_ptr = 
reinterpret_cast<const char*
>(&
s);
 
  100    if (!std::less{}(
s.data(), s_ptr) && !std::greater{}(
s.data() + 
s.size(), s_ptr + 
sizeof(
s))) {
 
  106template<
unsigned int N, 
typename X, 
typename S, 
typename D>
 
  112template<
typename X, 
typename Y>
 
  118template<
typename X, 
typename Y>
 
  124template<
typename X, 
typename Y, 
typename Z>
 
  130template<
typename X, 
typename Y, 
typename Z>
 
  138template<
typename X, 
typename Y>
 
  144template<
typename X, 
typename Y>
 
  187template<
typename X, 
typename Y>
 
  193template<
typename X, 
typename Y, 
typename Z>
 
  199template <
class Key, 
class T, 
class Hash, 
class Pred, std::
size_t MAX_BLOCK_SIZE_BYTES, std::
size_t ALIGN_BYTES>
 
  205                                                                         MAX_BLOCK_SIZE_BYTES,
 
  208    auto* pool_resource = 
m.get_allocator().resource();
 
  212    size_t estimated_list_node_size = 
MallocUsage(
sizeof(
void*) * 3);
 
  213    size_t usage_resource = estimated_list_node_size * pool_resource->NumAllocatedChunks();
 
  214    size_t usage_chunks = 
MallocUsage(pool_resource->ChunkSizeBytes()) * pool_resource->NumAllocatedChunks();
 
  215    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.