13 #include <unordered_map>
71 struct MemoryStatistics {
72 bool IsBalanced()
const;
74 int64_t count_malloc_ = 0;
75 int64_t count_free_ = 0;
76 std::unordered_map<void*, size_t> active_allocations_;
84 bool print_at_program_end_ =
true;
87 bool print_at_malloc_free_ =
false;
89 std::mutex statistics_mutex_;
90 std::map<Device, MemoryStatistics> statistics_;
Definition: MemoryManagerStatistic.h:20
void CountFree(void *ptr, const Device &device)
Definition: MemoryManagerStatistic.cpp:143
static MemoryManagerStatistic & GetInstance()
Definition: MemoryManagerStatistic.cpp:19
bool HasLeaks() const
Definition: MemoryManagerStatistic.cpp:111
~MemoryManagerStatistic()
Definition: MemoryManagerStatistic.cpp:30
void SetPrintAtProgramEnd(bool print)
Definition: MemoryManagerStatistic.cpp:48
void Print() const
Prints statistics for all recorded devices depending on the print level.
Definition: MemoryManagerStatistic.cpp:56
void Reset()
Resets the statistics.
Definition: MemoryManagerStatistic.cpp:172
void SetPrintLevel(PrintLevel level)
Sets the level of provided information for printing.
Definition: MemoryManagerStatistic.cpp:46
MemoryManagerStatistic & operator=(MemoryManagerStatistic &)=delete
PrintLevel
Definition: MemoryManagerStatistic.h:22
@ None
No statistics are printed.
@ All
Statistics for all used devices are printed.
void SetPrintAtMallocFree(bool print)
Enables or disables printing at each malloc and free.
Definition: MemoryManagerStatistic.cpp:52
void CountMalloc(void *ptr, size_t byte_size, const Device &device)
Adds the given allocation to the statistics.
Definition: MemoryManagerStatistic.cpp:118
MemoryManagerStatistic(const MemoryManagerStatistic &)=delete
Definition: PinholeCameraIntrinsic.cpp:16