ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::core::MemoryManagerStatistic Class Reference

#include <MemoryManagerStatistic.h>

Public Types

enum class  PrintLevel { All = 0 , Unbalanced = 1 , None = 2 }
 

Public Member Functions

 MemoryManagerStatistic (const MemoryManagerStatistic &)=delete
 
MemoryManagerStatisticoperator= (MemoryManagerStatistic &)=delete
 
 ~MemoryManagerStatistic ()
 
void SetPrintLevel (PrintLevel level)
 Sets the level of provided information for printing. More...
 
void SetPrintAtProgramEnd (bool print)
 
void SetPrintAtMallocFree (bool print)
 Enables or disables printing at each malloc and free. More...
 
void Print () const
 Prints statistics for all recorded devices depending on the print level. More...
 
bool HasLeaks () const
 
void CountMalloc (void *ptr, size_t byte_size, const Device &device)
 Adds the given allocation to the statistics. More...
 
void CountFree (void *ptr, const Device &device)
 
void Reset ()
 Resets the statistics. More...
 

Static Public Member Functions

static MemoryManagerStatisticGetInstance ()
 

Detailed Description

Definition at line 20 of file MemoryManagerStatistic.h.

Member Enumeration Documentation

◆ PrintLevel

Enumerator
All 

Statistics for all used devices are printed.

Unbalanced 

Only devices with unbalanced counts are printed. This is typically an indicator for memory leaks.

None 

No statistics are printed.

Definition at line 22 of file MemoryManagerStatistic.h.

Constructor & Destructor Documentation

◆ MemoryManagerStatistic()

cloudViewer::core::MemoryManagerStatistic::MemoryManagerStatistic ( const MemoryManagerStatistic )
delete

◆ ~MemoryManagerStatistic()

cloudViewer::core::MemoryManagerStatistic::~MemoryManagerStatistic ( )

Member Function Documentation

◆ CountFree()

void cloudViewer::core::MemoryManagerStatistic::CountFree ( void *  ptr,
const Device device 
)

Adds the given deallocations to the statistics. Counts for previously recorded allocations after a reset are ignored for consistency.

Definition at line 143 of file MemoryManagerStatistic.cpp.

References LogError, LogInfo, and cloudViewer::core::Device::ToString().

Referenced by cloudViewer::core::MemoryManager::Free().

◆ CountMalloc()

void cloudViewer::core::MemoryManagerStatistic::CountMalloc ( void *  ptr,
size_t  byte_size,
const Device device 
)

Adds the given allocation to the statistics.

Definition at line 118 of file MemoryManagerStatistic.cpp.

References LogError, LogInfo, and cloudViewer::core::Device::ToString().

Referenced by cloudViewer::core::MemoryManager::Malloc().

◆ GetInstance()

MemoryManagerStatistic & cloudViewer::core::MemoryManagerStatistic::GetInstance ( )
static

◆ HasLeaks()

bool cloudViewer::core::MemoryManagerStatistic::HasLeaks ( ) const

Returns true if any recorded device has unbalanced counts, false otherwise.

Definition at line 111 of file MemoryManagerStatistic.cpp.

Referenced by Print(), and ~MemoryManagerStatistic().

◆ operator=()

MemoryManagerStatistic& cloudViewer::core::MemoryManagerStatistic::operator= ( MemoryManagerStatistic )
delete

◆ Print()

void cloudViewer::core::MemoryManagerStatistic::Print ( ) const

Prints statistics for all recorded devices depending on the print level.

Definition at line 56 of file MemoryManagerStatistic.cpp.

References count, cloudViewer::utility::GetVerbosityLevel(), HasLeaks(), cloudViewer::utility::Info, LogInfo, LogWarning, None, cloudViewer::utility::SetVerbosityLevel(), and Unbalanced.

Referenced by ~MemoryManagerStatistic().

◆ Reset()

void cloudViewer::core::MemoryManagerStatistic::Reset ( )

Resets the statistics.

Definition at line 172 of file MemoryManagerStatistic.cpp.

Referenced by cloudViewer::PYBIND11_MODULE().

◆ SetPrintAtMallocFree()

void cloudViewer::core::MemoryManagerStatistic::SetPrintAtMallocFree ( bool  print)

Enables or disables printing at each malloc and free.

Definition at line 52 of file MemoryManagerStatistic.cpp.

◆ SetPrintAtProgramEnd()

void cloudViewer::core::MemoryManagerStatistic::SetPrintAtProgramEnd ( bool  print)

Enables or disables printing at the program end. Printing at the program end additionally overrides the exit code to EXIT_FAILURE in the presence of leaks.

Definition at line 48 of file MemoryManagerStatistic.cpp.

◆ SetPrintLevel()

void cloudViewer::core::MemoryManagerStatistic::SetPrintLevel ( PrintLevel  level)

Sets the level of provided information for printing.

Definition at line 46 of file MemoryManagerStatistic.cpp.


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