From 428b7da1cc3464c9ee6742c3f760d79950da5f0d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 27 Sep 2018 23:18:47 +0200 Subject: [PATCH] The underlying vector might be reallocated. --- server/TracyView.cpp | 12 ++++++++++-- server/TracyView.hpp | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 312aee67..7387c618 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -7573,7 +7573,7 @@ void View::DrawFrameTreeLevel( std::vector& tree, int& idx ) { if( v.callstacks.find( mem[i].csAlloc ) != v.callstacks.end() ) { - m_memInfo.allocList.emplace_back( mem.data() + i ); + m_memInfo.allocList.emplace_back( i ); } } } @@ -7670,9 +7670,17 @@ void View::DrawFrameTreeLevel( std::vector& tree, int& idx ) void View::DrawAllocList() { + std::vector data; + auto basePtr = m_worker.GetMemData().data.data(); + data.reserve( m_memInfo.allocList.size() ); + for( auto& idx : m_memInfo.allocList ) + { + data.emplace_back( basePtr + idx ); + } + ImGui::Begin( "Allocations list", &m_memInfo.showAllocList ); TextFocused( "Number of allocations:", RealToString( m_memInfo.allocList.size(), true ) ); - ListMemData( m_memInfo.allocList.begin(), m_memInfo.allocList.end(), [this]( auto& v ) { + ListMemData( data.begin(), data.end(), [this]( auto& v ) { ImGui::Text( "0x%" PRIx64, (*v)->ptr ); }, "##allocations" ); ImGui::End(); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 23150f09..cb06d2e6 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -404,7 +404,7 @@ private: uint64_t ptrFind = 0; bool restrictTime = false; bool showAllocList = false; - std::vector allocList; + std::vector allocList; } m_memInfo; struct {