SST  7.1.0
StructuralSimulationToolkit
SST::Core::MemPool Class Reference

Simple Memory Pool class. More...

#include <mempool.h>

Public Member Functions

 MemPool (size_t elementSize, size_t initialSize=(2<< 20))
 Create a new Memory Pool. More...
 
void * malloc ()
 Allocate a new element from the memory pool.
 
void free (void *ptr)
 Return an element to the memory pool.
 
uint64_t getBytesMemUsed ()
 Approximates the current memory usage of the mempool. More...
 
uint64_t getUndeletedEntries ()
 
size_t getArenaSize () const
 
size_t getElementSize () const
 
const std::list< uint8_t * > & getArenas ()
 

Data Fields

std::atomic< uint64_t > numAlloc
 Counter: Number of times elements have been allocated.
 
std::atomic< uint64_t > numFree
 Counter: Number times elements have been freed.
 

Detailed Description

Simple Memory Pool class.

Constructor & Destructor Documentation

◆ MemPool()

SST::Core::MemPool::MemPool ( size_t  elementSize,
size_t  initialSize = (2<<20) 
)
inline

Create a new Memory Pool.

Parameters
elementSize- Size of each Element
initialSize- Size of the memory pool (in bytes)

References free().

Member Function Documentation

◆ getBytesMemUsed()

uint64_t SST::Core::MemPool::getBytesMemUsed ( )
inline

Approximates the current memory usage of the mempool.

Some overheads are not taken into account.

References numAlloc, and numFree.


The documentation for this class was generated from the following file: