overload global new/delete to observe allocations
This commit is contained in:
parent
74207a0b63
commit
0c29b828c4
18
main.cc
18
main.cc
@ -2,6 +2,7 @@
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
@ -614,3 +615,20 @@ int main(int, char**) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void* operator new(size_t n) {
|
||||
auto ptr = std::malloc(n);
|
||||
if (!ptr) {
|
||||
throw nf7::Exception {"allocation failure"};
|
||||
}
|
||||
TracyAlloc(ptr, n);
|
||||
return ptr;
|
||||
}
|
||||
void operator delete(void* ptr) noexcept {
|
||||
TracyFree(ptr);
|
||||
std::free(ptr);
|
||||
}
|
||||
void operator delete(void* ptr, size_t) noexcept {
|
||||
operator delete(ptr);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user