diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index d61ea061..857bd5e7 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1208,17 +1208,6 @@ bool Profiler::ShouldExit() return s_instance->m_shutdown.load( std::memory_order_relaxed ); } -class ThreadExitHandler -{ -public: - ~ThreadExitHandler() - { -#ifdef TRACY_MANUAL_LIFETIME - rpmalloc_thread_finalize(); -#endif - } -}; - void Profiler::Worker() { #ifdef __linux__ diff --git a/client/TracySysTrace.cpp b/client/TracySysTrace.cpp index 68652886..653ada21 100644 --- a/client/TracySysTrace.cpp +++ b/client/TracySysTrace.cpp @@ -321,6 +321,7 @@ static void SetupVsync() s_threadVsync = (Thread*)tracy_malloc( sizeof( Thread ) ); new(s_threadVsync) Thread( [] (void*) { + ThreadExitHandler threadExitHandler; SetThreadName( "Tracy Vsync" ); ProcessTrace( &s_traceHandleVsync2, 1, nullptr, nullptr ); }, nullptr ); @@ -455,6 +456,7 @@ void SysTraceStop() void SysTraceWorker( void* ptr ) { + ThreadExitHandler threadExitHandler; SetThreadName( "Tracy SysTrace" ); ProcessTrace( &s_traceHandle2, 1, 0, 0 ); ControlTrace( 0, KERNEL_LOGGER_NAME, s_prop, EVENT_TRACE_CONTROL_STOP ); @@ -955,6 +957,7 @@ static void ProcessTraceLines( int fd ) void SysTraceWorker( void* ptr ) { + ThreadExitHandler threadExitHandler; SetThreadName( "Tracy SysTrace" ); int pipefd[2]; if( pipe( pipefd ) == 0 ) @@ -1028,6 +1031,7 @@ static void ProcessTraceLines( int fd ) void SysTraceWorker( void* ptr ) { + ThreadExitHandler threadExitHandler; SetThreadName( "Tracy SysTrace" ); char tmp[256]; memcpy( tmp, BasePath, sizeof( BasePath ) - 1 ); diff --git a/client/TracyThread.hpp b/client/TracyThread.hpp index 7fca497b..28c64c54 100644 --- a/client/TracyThread.hpp +++ b/client/TracyThread.hpp @@ -10,6 +10,17 @@ namespace tracy { +class ThreadExitHandler +{ +public: + ~ThreadExitHandler() + { +#ifdef TRACY_MANUAL_LIFETIME + rpmalloc_thread_finalize(); +#endif + } +}; + #if defined _WIN32 || defined __CYGWIN__ class Thread