diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 52d3650e..1261b658 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -20,6 +20,7 @@ #include "../common/TracySocket.hpp" #include "../common/TracySystem.hpp" #include "tracy_rpmalloc.hpp" +#include "TracyAlloc.hpp" #include "TracyScoped.hpp" #include "TracyProfiler.hpp" @@ -39,13 +40,11 @@ namespace tracy struct RPMallocInit { RPMallocInit() { rpmalloc_initialize(); } - ~RPMallocInit() { rpmalloc_finalize(); } }; struct RPMallocThreadInit { RPMallocThreadInit() { rpmalloc_thread_initialize(); } - ~RPMallocThreadInit() { rpmalloc_thread_finalize(); } }; static const char* GetProcessName() @@ -86,7 +85,7 @@ Profiler::Profiler() , m_epoch( std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch() ).count() ) , m_shutdown( false ) , m_stream( LZ4_createStream() ) - , m_buffer( new char[TargetFrameSize*3] ) + , m_buffer( (char*)tracy_malloc( TargetFrameSize*3 ) ) , m_bufferOffset( 0 ) { assert( !s_instance ); @@ -106,7 +105,7 @@ Profiler::~Profiler() m_shutdown.store( true, std::memory_order_relaxed ); m_thread.join(); - delete[] m_buffer; + tracy_free( m_buffer ); LZ4_freeStream( m_stream ); assert( s_instance ); @@ -276,7 +275,7 @@ bool Profiler::HandleServerQuery() break; case ServerQueryCustomString: SendString( ptr, (const char*)ptr, QueueType::CustomStringData ); - delete[] (const char*)ptr; + tracy_free( (void*)ptr ); break; case ServerQuerySourceLocation: SendSourceLocation( ptr ); @@ -286,7 +285,7 @@ bool Profiler::HandleServerQuery() break; case ServerQueryMessage: SendString( ptr, (const char*)ptr, QueueType::MessageData ); - delete[] (const char*)ptr; + tracy_free( (void*)ptr ); break; default: assert( false ); diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index 5558ba86..a7de1fcb 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -9,6 +9,7 @@ #include "concurrentqueue.h" #include "../common/tracy_lz4.hpp" #include "../common/TracyQueue.hpp" +#include "TracyAlloc.hpp" #if defined _MSC_VER || defined __CYGWIN__ # include @@ -131,7 +132,7 @@ public: { uint32_t cpu; Magic magic; - auto ptr = new char[size+1]; + auto ptr = (char*)tracy_malloc( size+1 ); memcpy( ptr, txt, size ); ptr[size] = '\0'; auto& token = s_token.ptr; diff --git a/client/TracyScoped.hpp b/client/TracyScoped.hpp index 99155745..263cd507 100644 --- a/client/TracyScoped.hpp +++ b/client/TracyScoped.hpp @@ -5,6 +5,7 @@ #include #include "../common/TracySystem.hpp" +#include "TracyAlloc.hpp" #include "TracyProfiler.hpp" namespace tracy @@ -43,7 +44,7 @@ public: tracy_force_inline void Text( const char* txt, size_t size ) { Magic magic; - auto ptr = new char[size+1]; + auto ptr = (char*)tracy_malloc( size+1 ); memcpy( ptr, txt, size ); ptr[size] = '\0'; auto& token = s_token.ptr;