![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
#include <MemoryManagerStatistic.h>
Public Types | |
| enum class | PrintLevel { All = 0 , Unbalanced = 1 , None = 2 } |
Public Member Functions | |
| MemoryManagerStatistic (const MemoryManagerStatistic &)=delete | |
| MemoryManagerStatistic & | operator= (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 MemoryManagerStatistic & | GetInstance () |
Definition at line 20 of file MemoryManagerStatistic.h.
| 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.
|
delete |
| cloudViewer::core::MemoryManagerStatistic::~MemoryManagerStatistic | ( | ) |
Definition at line 30 of file MemoryManagerStatistic.cpp.
References cloudViewer::utility::Logger::GetInstance(), HasLeaks(), Print(), and cloudViewer::utility::Logger::ResetPrintFunction().
| 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().
| 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().
|
static |
Definition at line 19 of file MemoryManagerStatistic.cpp.
References cloudViewer::utility::Logger::GetInstance().
Referenced by cloudViewer::core::MemoryManager::Free(), cloudViewer::core::MemoryManager::Malloc(), and cloudViewer::PYBIND11_MODULE().
| 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().
|
delete |
| 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().
| void cloudViewer::core::MemoryManagerStatistic::Reset | ( | ) |
Resets the statistics.
Definition at line 172 of file MemoryManagerStatistic.cpp.
Referenced by cloudViewer::PYBIND11_MODULE().
| void cloudViewer::core::MemoryManagerStatistic::SetPrintAtMallocFree | ( | bool | ) |
Enables or disables printing at each malloc and free.
Definition at line 52 of file MemoryManagerStatistic.cpp.
| void cloudViewer::core::MemoryManagerStatistic::SetPrintAtProgramEnd | ( | bool | ) |
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.
| void cloudViewer::core::MemoryManagerStatistic::SetPrintLevel | ( | PrintLevel | level | ) |
Sets the level of provided information for printing.
Definition at line 46 of file MemoryManagerStatistic.cpp.