From 40efbe8529166b3ab62175f8ea5576cdc2d628db Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 10 Apr 2021 13:02:32 +0200 Subject: [PATCH] Use rpmalloc for initialization-related allocations. --- client/TracyProfiler.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 7880708e..bcf43942 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -972,7 +972,6 @@ void InitRPMallocThread() struct ProfilerData { int64_t initTime = SetupHwTimer(); - RPMallocInit rpmalloc_init; moodycamel::ConcurrentQueue queue; Profiler profiler; std::atomic lockCounter { 0 }; @@ -1002,7 +1001,9 @@ struct ProfilerThreadData ProfilerData* s_profilerData = nullptr; TRACY_API void StartupProfiler() { - s_profilerData = new ProfilerData; + RPMallocInit init; + s_profilerData = (ProfilerData*)tracy_malloc( sizeof( ProfilerData ) ); + new (s_profilerData) ProfilerData(); s_profilerData->profiler.SpawnWorkerThreads(); } static ProfilerData& GetProfilerData() @@ -1012,7 +1013,8 @@ static ProfilerData& GetProfilerData() } TRACY_API void ShutdownProfiler() { - delete s_profilerData; + s_profilerData->~ProfilerData(); + tracy_free( s_profilerData ); s_profilerData = nullptr; rpmalloc_finalize(); } @@ -1030,7 +1032,8 @@ static ProfilerData& GetProfilerData() ptr = profilerData.load( std::memory_order_acquire ); if( !ptr ) { - ptr = (ProfilerData*)malloc( sizeof( ProfilerData ) ); + RPMallocInit init; + ptr = (ProfilerData*)tracy_malloc( sizeof( ProfilerData ) ); new (ptr) ProfilerData(); profilerData.store( ptr, std::memory_order_release ); }