From bbf1e9f1118a6249a021fb98a4b703c5b63b41e1 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 2 May 2018 18:13:13 +0200 Subject: [PATCH] Only include memory events from zone thread. --- server/TracyView.cpp | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 710d9ca9..8e3ea3c9 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -2678,6 +2678,8 @@ void View::DrawZoneInfoWindow() { ImGui::Separator(); + const auto thread = m_worker.CompressThread( tid ); + auto ait = std::lower_bound( mem.data.begin(), mem.data.end(), ev.start, [] ( const auto& l, const auto& r ) { return l.timeAlloc < r; } ); const auto aend = std::upper_bound( mem.data.begin(), mem.data.end(), end, [] ( const auto& l, const auto& r ) { return l < r.timeAlloc; } ); @@ -2692,29 +2694,45 @@ void View::DrawZoneInfoWindow() } else { - ImGui::Text( "%s memory events.", RealToString( aDist + fDist, true ) ); - int64_t change = 0; int64_t cAlloc = 0; int64_t cFree = 0; + int64_t nAlloc = 0; + int64_t nFree = 0; while( ait != aend ) { - change += ait->size; - cAlloc += ait->size; + if( ait->threadAlloc == thread ) + { + change += ait->size; + cAlloc += ait->size; + nAlloc++; + } ait++; } while( fit != fend ) { - change -= mem.data[*fit].size; - cFree += mem.data[*fit].size; + if( mem.data[*fit].threadFree == thread ) + { + change -= mem.data[*fit].size; + cFree += mem.data[*fit].size; + nFree++; + } fit++; } - ImGui::Text( "%s allocs, %s frees.", RealToString( aDist, true ), RealToString( fDist, true ) ); - ImGui::Text( "Memory allocated: %s bytes", RealToString( cAlloc, true ) ); - ImGui::Text( "Memory freed: %s bytes", RealToString( cFree, true ) ); - ImGui::Text( "Overall change: %s bytes", RealToString( change, true ) ); + if( nAlloc == 0 && nFree == 0 ) + { + ImGui::Text( "No memory events." ); + } + else + { + ImGui::Text( "%s memory events.", RealToString( nAlloc + nFree, true ) ); + ImGui::Text( "%s allocs, %s frees.", RealToString( nAlloc, true ), RealToString( nFree, true ) ); + ImGui::Text( "Memory allocated: %s bytes", RealToString( cAlloc, true ) ); + ImGui::Text( "Memory freed: %s bytes", RealToString( cFree, true ) ); + ImGui::Text( "Overall change: %s bytes", RealToString( change, true ) ); + } } }