commonlib
MemoryWatch Class Reference

Finding Memory Leaks class using the CRT Library. More...

#include <memorywatch.h>

Public Types

using CurrentMemoryState = _CrtMemState
 Memory state structure at some key point (used for passing to _CrtMemCheckpoint)
 

Static Public Member Functions

static bool EnableMemoryLeakChecking (const std::string &reportFilePath="", MemoryWatchReport leakReport=MemoryWatchReport::fileAndOutput)
 EnableMemoryLeakChecking Enables memory leak reporting in your application. More...
 
static void SetMemoryCheckpoint (_CrtMemState *state)
 Function fills in the structure (_CrtMemState) with a snapshot of the current memory state. More...
 
static int CompareMemoryCheckpoints (_CrtMemState *difference, _CrtMemState const *oldState, _CrtMemState const *newState)
 CompareMemoryCheckpoints compares the memory states oldState and newState and returns a result in the difference of oldState and newState. More...
 
static void DumpMemoryCheckpointsLog (_CrtMemState const *state)
 DumpMemoryCheckpointsLog Outputs a dump of memory state. More...
 

Detailed Description

Finding Memory Leaks class using the CRT Library.

Member Function Documentation

◆ CompareMemoryCheckpoints()

static int MemoryWatch::CompareMemoryCheckpoints ( _CrtMemState *  difference,
_CrtMemState const *  oldState,
_CrtMemState const *  newState 
)
static

CompareMemoryCheckpoints compares the memory states oldState and newState and returns a result in the difference of oldState and newState.

Parameters
differenceA _CrtMemState pointer.
oldStateA constant _CrtMemState pointer.
newStateA constant _CrtMemState pointer.
Returns
int If return value is different from 0 then memory leak occured.

◆ DumpMemoryCheckpointsLog()

static void MemoryWatch::DumpMemoryCheckpointsLog ( _CrtMemState const *  state)
static

DumpMemoryCheckpointsLog Outputs a dump of memory state.

Parameters
stateA constant _CrtMemState pointer.

◆ EnableMemoryLeakChecking()

static bool MemoryWatch::EnableMemoryLeakChecking ( const std::string &  reportFilePath = "",
MemoryWatchReport  leakReport = MemoryWatchReport::fileAndOutput 
)
static

EnableMemoryLeakChecking Enables memory leak reporting in your application.

Parameters
reportFilePathA constant string with path to memory leak report file.
leakReportA MemoryWatchReport type (file, file and output, file and window or all).
Returns
bool If true then memory leak checking is turned on.

◆ SetMemoryCheckpoint()

static void MemoryWatch::SetMemoryCheckpoint ( _CrtMemState *  state)
static

Function fills in the structure (_CrtMemState) with a snapshot of the current memory state.

Parameters
stateA _CrtMemState pointer.

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