MallocCount Namespace Reference

Typedefs

using Callback = std::function< void(size_t current)>
 Callback function type. More...
 

Functions

size_t getCurrent (void)
 Get the currently allocated amount of memory. More...
 
size_t getPeak (void)
 Get the peak memory allocation. More...
 
void resetPeak (void)
 Reset the peak memory allocation to current. More...
 
size_t getTotal (void)
 Get the total cumulative memory allocation. More...
 
void resetTotal (void)
 Reset the total cumulative memory allocation to zero. More...
 
size_t getAllocCount (void)
 Get the total number of allocations. More...
 
void setAllocLimit (size_t maxBytes)
 Set an allocation limit. More...
 
void setCallback (Callback callback)
 Set a callback function that is invoked on each change of the current allocation. More...
 
void enableLogging (bool enable)
 Enable/disable logging. More...
 
void setLogThreshold (size_t threshold)
 Set minimum allocation size for log output (when enabled) More...
 

Typedef Documentation

◆ Callback

using MallocCount::Callback = typedef std::function<void(size_t current)>

Callback function type.

Parameters
currentCurrent allocated bytes

Function Documentation

◆ enableLogging()

void MallocCount::enableLogging ( bool  enable)

Enable/disable logging.

◆ getAllocCount()

size_t MallocCount::getAllocCount ( void  )

Get the total number of allocations.

◆ getCurrent()

size_t MallocCount::getCurrent ( void  )

Get the currently allocated amount of memory.

◆ getPeak()

size_t MallocCount::getPeak ( void  )

Get the peak memory allocation.

◆ getTotal()

size_t MallocCount::getTotal ( void  )

Get the total cumulative memory allocation.

◆ resetPeak()

void MallocCount::resetPeak ( void  )

Reset the peak memory allocation to current.

◆ resetTotal()

void MallocCount::resetTotal ( void  )

Reset the total cumulative memory allocation to zero.

◆ setAllocLimit()

void MallocCount::setAllocLimit ( size_t  maxBytes)

Set an allocation limit.

Parameters
maxBytesSpecify 0 for no limit

◆ setCallback()

void MallocCount::setCallback ( Callback  callback)

Set a callback function that is invoked on each change of the current allocation.

Note
The callback function must not use malloc()/realloc()/free() or it will go into an endless recursive loop!

◆ setLogThreshold()

void MallocCount::setLogThreshold ( size_t  threshold)

Set minimum allocation size for log output (when enabled)