diff --git a/examples/dyna/src/main.cpp b/examples/dyna/src/main.cpp index 2225c388..68f21f9a 100644 --- a/examples/dyna/src/main.cpp +++ b/examples/dyna/src/main.cpp @@ -4,6 +4,26 @@ #include #include +#include +#include + +// Route every heap allocation through Tracy so the profiler can track memory +// usage. The default array forms (operator new[]/delete[]) and the nothrow +// forms forward to these, so overriding the scalar operators covers them too. +void* operator new( std::size_t count ) +{ + void* ptr = std::malloc( count ); + if( !ptr ) throw std::bad_alloc(); + TracyAlloc( ptr, count ); + return ptr; +} + +void operator delete( void* ptr ) noexcept +{ + TracyFree( ptr ); + std::free( ptr ); +} + int main( int /*argc*/, char* /*argv*/[] ) { TracyNoop;