From 5eb3e3a1f0933b00820830b0b1d18b8fb8a4ee88 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 24 Mar 2022 14:28:27 +0000 Subject: [PATCH] set s_numCpus before reading it --- client/TracySysTrace.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/TracySysTrace.cpp b/client/TracySysTrace.cpp index d078e240..cb455090 100644 --- a/client/TracySysTrace.cpp +++ b/client/TracySysTrace.cpp @@ -817,6 +817,8 @@ bool SysTraceStart( int64_t& samplingPeriod ) samplingPeriod = GetSamplingPeriod(); uint32_t currentPid = (uint32_t)getpid(); + s_numCpus = (int)std::thread::hardware_concurrency(); + const auto maxNumBuffers = s_numCpus * ( 1 + // software sampling 2 + // CPU cycles + instructions retired @@ -824,7 +826,6 @@ bool SysTraceStart( int64_t& samplingPeriod ) 2 + // branch retired + miss 2 // context switches + wakeups ); - s_numCpus = (int)std::thread::hardware_concurrency(); s_ring = (RingBuffer*)tracy_malloc( sizeof( RingBuffer ) * maxNumBuffers ); s_numBuffers = 0;