diff --git a/public/client/TracyProfiler.cpp b/public/client/TracyProfiler.cpp index e5f54fd3..d073f0bb 100644 --- a/public/client/TracyProfiler.cpp +++ b/public/client/TracyProfiler.cpp @@ -2148,9 +2148,15 @@ void Profiler::Worker() while( s_symbolThreadGone.load() == false ) { YieldThread(); } #endif - // Client is exiting. #ifdef TRACY_HAS_SYSTEM_TRACING - // Stop filling queues with new data. + // On a typical shutdown scenario, the (global) Profiler object is destroyed by + // the C++ runtime when the client program returns from "main", and ~Profiler() + // takes care of calling StopSystemTracing(). However, a client may decide to + // manually RequestShutdown(), in which case ~Profile() may not execute before + // this Worker() thread goes through its teardown stages and reaches this point. + // To ensure that system tracing does not keep pushing data to the worker queue + // indefinitely (thus preventing this worker from terminating), we have to call + // StopSystemTracing() here as well to be safe: StopSystemTracing(); #endif