CookMem 1.4.0
A C++ memory context / allocator
Loading...
Searching...
No Matches
cookmem::StatsLogger Class Reference

#include <logger.h>

Public Member Functions

void logTrimEmptySegments ()
 
void logGetSegment (void *segment, std::size_t segmentSize)
 
void logFreeSegment (void *segment, std::size_t segmentSize)
 
void logAllocation (void *userPtr, std::size_t userSize, MemAllocType_et allocType)
 
void logReallocation (void *userPtr, std::size_t oldUserSize, std::size_t newUserSize)
 
void logDeallocation (void *userPtr, std::size_t userSize)
 
void logError (void *, MemError_et error, const char *file=__FILE__, int line=__LINE__)
 
MemStatistics & getStats ()
 
const MemStatistics & getStats () const
 

Detailed Description

A MemLogger that tracks allocation and segment usage statistics.

This class implements the interface of MemLogger without explicitly inheriting from it. This is to avoid the overhead of virtual function calls and allows inlining of the functions.

Member Function Documentation

◆ getStats() [1/2]

MemStatistics & cookmem::StatsLogger::getStats ( )
inline

Get the statistics.

Returns
the statistics gathered so far.

◆ getStats() [2/2]

const MemStatistics & cookmem::StatsLogger::getStats ( ) const
inline

Get the statistics.

Returns
the statistics gathered so far.

◆ logAllocation()

void cookmem::StatsLogger::logAllocation ( void *  userPtr,
std::size_t  userSize,
MemAllocType_et  allocType 
)
inline

Log the memory allocation.

Parameters
userPtrthe user pointer allocated.
userSizethe user requested size.
allocTypethe type of the allocation.

◆ logDeallocation()

void cookmem::StatsLogger::logDeallocation ( void *  userPtr,
std::size_t  userSize 
)
inline

Log the memory deallocation.

Parameters
userPtrthe user pointer allocated.
userSizethe user requested size.

◆ logError()

void cookmem::StatsLogger::logError ( void *  ,
MemError_et  error,
const char *  file = __FILE__,
int  line = __LINE__ 
)
inline

Report a memory error by throwing an exception.

Parameters
errorthe type of the error encountered.
filethe source file where the error was detected.
linethe line number where the error was detected.
Exceptions
Exceptionalways.

◆ logFreeSegment()

void cookmem::StatsLogger::logFreeSegment ( void *  segment,
std::size_t  segmentSize 
)
inline

Log the memory segment release.

Parameters
segmentthe segment released.
segmentSizethe segment size.

◆ logGetSegment()

void cookmem::StatsLogger::logGetSegment ( void *  segment,
std::size_t  segmentSize 
)
inline

Log the memory segment allocation.

Parameters
segmentthe segment obtained.
segmentSizethe segment size.

◆ logReallocation()

void cookmem::StatsLogger::logReallocation ( void *  userPtr,
std::size_t  oldUserSize,
std::size_t  newUserSize 
)
inline

Log the memory reallocation. This is only called when the new size is smaller than the original size.

Parameters
userPtrthe user pointer allocated.
oldUserSizethe old user size.
newUserSizethe new user size.

◆ logTrimEmptySegments()

void cookmem::StatsLogger::logTrimEmptySegments ( )
inline

Log a pool empty-segment trimming pass.


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