|
CookMem 1.6.0
A C++ memory context / allocator
|
#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 *message, const char *file=__FILE__, int line=__LINE__) |
| MemStatistics & | getStats () |
| const MemStatistics & | getStats () const |
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.
|
inline |
Get the statistics.
|
inline |
Get the statistics.
|
inline |
Log the memory allocation.
| userPtr | the user pointer allocated, or nullptr if the allocation failed. |
| userSize | the size of the allocation, as getSize () reports it: the requested size if the exact size is stored, and otherwise the requested size rounded up to the alignment. If the allocation failed, the requested size. |
| allocType | the type of the allocation. |
|
inline |
Log the memory deallocation.
| userPtr | the user pointer allocated. |
| userSize | the size of the allocation, as getSize () reports it, which is the size its allocation was logged with. |
|
inline |
Report a memory error by throwing an exception.
| error | the type of the error encountered. |
| message | a description of the error. |
| file | the source file where the error was detected. |
| line | the line number where the error was detected. |
| Exception | always. |
|
inline |
Log the memory segment release.
| segment | the segment released. |
| segmentSize | the segment size. |
|
inline |
Log the memory segment allocation.
| segment | the segment obtained. |
| segmentSize | the segment size. |
|
inline |
Log a reallocation in place, which grows or shrinks an allocation without moving it. A reallocation that moves the memory is logged as an allocation and a deallocation instead.
| userPtr | the user pointer, which does not change. |
| oldUserSize | the size before, as getSize () reported it. |
| newUserSize | the size after, as getSize () reports it. |
|
inline |
Log a pool empty-segment trimming pass.