The underlying vector might be reallocated.

This commit is contained in:
Bartosz Taudul 2018-09-27 23:18:47 +02:00
parent 6cfd53b274
commit 428b7da1cc
2 changed files with 11 additions and 3 deletions

View File

@ -7573,7 +7573,7 @@ void View::DrawFrameTreeLevel( std::vector<CallstackFrameTree>& 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<CallstackFrameTree>& tree, int& idx )
void View::DrawAllocList()
{
std::vector<const MemEvent*> 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<decltype( m_memInfo.allocList.begin() )>( m_memInfo.allocList.begin(), m_memInfo.allocList.end(), [this]( auto& v ) {
ListMemData<decltype( data.begin() )>( data.begin(), data.end(), [this]( auto& v ) {
ImGui::Text( "0x%" PRIx64, (*v)->ptr );
}, "##allocations" );
ImGui::End();

View File

@ -404,7 +404,7 @@ private:
uint64_t ptrFind = 0;
bool restrictTime = false;
bool showAllocList = false;
std::vector<const MemEvent*> allocList;
std::vector<size_t> allocList;
} m_memInfo;
struct {