29 #ifdef OCILIBPP_DEBUG_MEMORY_ENABLED
31 struct MemoryAllocation
42 std::vector<MemoryAllocation> Allocations;
46 void OnAllocate(T* address,
size_t count)
48 Allocations.push_back({ address,
typeid(T).name(),
sizeof(T), count });
52 void OnDeallocate(T* address)
54 auto it = std::find_if(std::begin(Allocations), std::end(Allocations), [address](
const auto& alloc)
56 return alloc.Address == address;
58 if (it != std::end(Allocations))
60 Allocations.erase(it);
64 void PrintAllocations()
66 if (Allocations.empty())
return;
68 std::cout <<
"Unfreed memory found" << std::endl;
70 for (
auto& alloc : Allocations)
72 std::cout <<
"=> Address " << alloc.Address
73 <<
" - Size " << alloc.Count
74 <<
" - Count " << alloc.Size
75 <<
" - Type " << alloc.Name
81 inline MemoryDebugInfo& GetMemoryDebugInfo()
83 static MemoryDebugInfo memoryDebugInfo;
85 return memoryDebugInfo;