Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

# Keos::CMemoryManager Class Reference

Memory manager, detects the memory leaks. More...

`#include <KeosMemoryManager.h>`

List of all members.

## Public Member Functions

void * | Allocate (size_t nSize, const CFile &File, int nLine, bool bArray)
| Add an allocation memory.
void | Free (void *pPtr, bool bArray)
| Remove an allocation memory.
void | NextDelete (const CFile &File, int nLine)
| Back up the information about the current deallocation.
| ~CMemoryManager ()
| Destructor.

## Static Public Member Functions

static CMemoryManager & | Instance ()
| Return the class instance.

## Private Types

typedef std::map< void *, TBlock > | TBlockMap

## Private Member Functions

| CMemoryManager ()
| Default constructor.
void | ReportLeaks ()
| Log the report on the memory leaks.

## Private Attributes

std::ofstream | m_File
| Output file.
TBlockMap | m_Blocks
| Memory blocks allocated.
std::stack< TBlock > | m_DeleteStack
| Stack whose summit contains the line and the file of the next deallocation.

## Classes

struct | TBlock

## Detailed Description

Memory manager, detects the memory leaks.

Definition at line 63 of file KeosMemoryManager.h.

## Member Typedef Documentation

typedef std::map<void*, TBlock> Keos::CMemoryManager::TBlockMap`[private]`

| Definition at line 118 of file KeosMemoryManager.h.

## Constructor & Destructor Documentation

Keos::CMemoryManager::~CMemoryManager | ( |  | ) |

| Destructor. Definition at line 75 of file KeosMemoryManager.cpp. References m_Blocks, m_File, and ReportLeaks().

Keos::CMemoryManager::CMemoryManager | ( |  | ) | `[private]`

| Default constructor. Definition at line 59 of file KeosMemoryManager.cpp. References KEOS_MEMLEAKS_FILE, KEOS_VERSION_MAJOR, KEOS_VERSION_MINOR, KEOS_VERSION_PATCH, and m_File.

## Member Function Documentation

void * Keos::CMemoryManager::Allocate | ( | size_t | nSize,
|  | const CFile & | File,
|  | int | nLine,
|  | bool | bArray
| ) |

| Add an allocation memory.

Parameters:

  | nSize | Allocated size.
  | File | File containing the allowance.
  | nLine | Line of the allowance.
  | bArray | True if it is an allowance of array.

Returns:
  Pointer on the allocated memory.

Definition at line 133 of file KeosMemoryManager.cpp.

References Keos::CMemoryManager::TBlock::bArray, Keos::CMemoryManager::TBlock::File, Keos::CFile::Filename(), m_Blocks, m_File, Keos::CMemoryManager::TBlock::nLine, and Keos::CMemoryManager::TBlock::nSize.

void Keos::CMemoryManager::Free | ( | void * | pPtr,
|  | bool | bArray
| ) |

| Remove an allocation memory.

Parameters:

  | pPtr | Address of the memory deallocated.
  | bArray | True if it is an deallocation of array.

Definition at line 155 of file KeosMemoryManager.cpp.

References Keos::CMemoryManager::TBlock::File, Keos::CFile::Filename(), m_Blocks, m_DeleteStack, and m_File.

CMemoryManager & Keos::CMemoryManager::Instance | ( |  | ) | `[static]`

| Return the class instance.

Returns:
  Reference on the unique instance of the class.

Definition at line 99 of file KeosMemoryManager.cpp.

void Keos::CMemoryManager::NextDelete | ( | const CFile & | File,
|  | int | nLine
| ) |

| Back up the information about the current deallocation.

Parameters:

  | File | File containing the deallocation.
  | nLine | Line of the deallocation.

Definition at line 188 of file KeosMemoryManager.cpp.

References Keos::CMemoryManager::TBlock::File, m_DeleteStack, and Keos::CMemoryManager::TBlock::nLine.

void Keos::CMemoryManager::ReportLeaks | ( |  | ) | `[private]`

| Log the report on the memory leaks. Definition at line 107 of file KeosMemoryManager.cpp. References m_Blocks, m_File, and size_t. Referenced by ~CMemoryManager().

## Member Data Documentation

TBlockMap Keos::CMemoryManager::m_Blocks`[private]`

| Memory blocks allocated. Definition at line 123 of file KeosMemoryManager.h. Referenced by Allocate(), Free(), ReportLeaks(), and ~CMemoryManager().

std::stack<TBlock> Keos::CMemoryManager::m_DeleteStack`[private]`

| Stack whose summit contains the line and the file of the next deallocation. Definition at line 125 of file KeosMemoryManager.h. Referenced by Free(), and NextDelete().

std::ofstream Keos::CMemoryManager::m_File`[private]`

| Output file. Definition at line 121 of file KeosMemoryManager.h. Referenced by Allocate(), CMemoryManager(), Free(), ReportLeaks(), and ~CMemoryManager().

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

- KeosEngine/KeosMemoryManager.h
- KeosEngine/KeosMemoryManager.cpp