mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 20:33:52 +00:00
Clip memory allocation lists.
This commit is contained in:
parent
a84eec1aef
commit
d680fa6cd6
@ -6200,7 +6200,7 @@ void View::DrawZoneInfoWindow()
|
|||||||
}
|
}
|
||||||
pdqsort_branchless( v.begin(), v.end(), [] ( const auto& l, const auto& r ) { return l->TimeAlloc() < r->TimeAlloc(); } );
|
pdqsort_branchless( v.begin(), v.end(), [] ( const auto& l, const auto& r ) { return l->TimeAlloc() < r->TimeAlloc(); } );
|
||||||
|
|
||||||
ListMemData<decltype( v.begin() )>( v.begin(), v.end(), []( auto& v ) {
|
ListMemData<decltype( v.begin() )>( v.begin(), v.end(), []( auto v ) {
|
||||||
ImGui::Text( "0x%" PRIx64, (*v)->Ptr() );
|
ImGui::Text( "0x%" PRIx64, (*v)->Ptr() );
|
||||||
}, nullptr, m_allocTimeRelativeToZone ? ev.Start() : -1 );
|
}, nullptr, m_allocTimeRelativeToZone ? ev.Start() : -1 );
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
@ -12572,7 +12572,7 @@ void View::DrawAnnotationList()
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void View::ListMemData( T ptr, T end, std::function<void(T&)> DrawAddress, const char* id, int64_t startTime )
|
void View::ListMemData( T ptr, T end, std::function<void(T)> DrawAddress, const char* id, int64_t startTime )
|
||||||
{
|
{
|
||||||
if( startTime == -1 ) startTime = 0;
|
if( startTime == -1 ) startTime = 0;
|
||||||
|
|
||||||
@ -12613,64 +12613,51 @@ void View::ListMemData( T ptr, T end, std::function<void(T&)> DrawAddress, const
|
|||||||
const auto& mem = m_worker.GetMemData();
|
const auto& mem = m_worker.GetMemData();
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
while( ptr != end )
|
ImGuiListClipper clipper( end - ptr );
|
||||||
|
while( clipper.Step() )
|
||||||
{
|
{
|
||||||
auto v = *ptr;
|
for( auto i=clipper.DisplayStart; i<clipper.DisplayEnd; i++ )
|
||||||
const auto arrIdx = std::distance( mem.data.begin(), v );
|
{
|
||||||
|
auto v = ptr[i];
|
||||||
|
const auto arrIdx = std::distance( mem.data.begin(), v );
|
||||||
|
|
||||||
if( m_memoryAllocInfoWindow == arrIdx )
|
if( m_memoryAllocInfoWindow == arrIdx )
|
||||||
{
|
|
||||||
ImGui::PushStyleColor( ImGuiCol_Text, ImVec4( 1.f, 0.f, 0.f, 1.f ) );
|
|
||||||
DrawAddress( ptr );
|
|
||||||
ImGui::PopStyleColor();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DrawAddress( ptr );
|
|
||||||
if( ImGui::IsItemClicked() )
|
|
||||||
{
|
{
|
||||||
m_memoryAllocInfoWindow = arrIdx;
|
ImGui::PushStyleColor( ImGuiCol_Text, ImVec4( 1.f, 0.f, 0.f, 1.f ) );
|
||||||
|
DrawAddress( ptr+i );
|
||||||
|
ImGui::PopStyleColor();
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
if( ImGui::IsItemClicked( 2 ) )
|
|
||||||
{
|
|
||||||
ZoomToRange( v->TimeAlloc(), v->TimeFree() >= 0 ? v->TimeFree() : m_worker.GetLastTime() );
|
|
||||||
}
|
|
||||||
if( ImGui::IsItemHovered() )
|
|
||||||
{
|
|
||||||
m_memoryAllocHover = arrIdx;
|
|
||||||
m_memoryAllocHoverWait = 2;
|
|
||||||
}
|
|
||||||
ImGui::NextColumn();
|
|
||||||
ImGui::TextUnformatted( MemSizeToString( v->Size() ) );
|
|
||||||
ImGui::NextColumn();
|
|
||||||
ImGui::PushID( idx++ );
|
|
||||||
if( ImGui::Selectable( TimeToString( v->TimeAlloc() - startTime ) ) )
|
|
||||||
{
|
|
||||||
CenterAtTime( v->TimeAlloc() );
|
|
||||||
}
|
|
||||||
ImGui::PopID();
|
|
||||||
ImGui::NextColumn();
|
|
||||||
if( v->TimeFree() < 0 )
|
|
||||||
{
|
|
||||||
TextColoredUnformatted( ImVec4( 0.6f, 1.f, 0.6f, 1.f ), TimeToString( m_worker.GetLastTime() - v->TimeAlloc() ) );
|
|
||||||
ImGui::NextColumn();
|
|
||||||
const auto tid = m_worker.DecompressThread( v->ThreadAlloc() );
|
|
||||||
SmallColorBox( GetThreadColor( tid, 0 ) );
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::TextUnformatted( m_worker.GetThreadName( tid ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ImGui::PushID( idx++ );
|
|
||||||
if( ImGui::Selectable( TimeToString( v->TimeFree() - v->TimeAlloc() ) ) )
|
|
||||||
{
|
{
|
||||||
CenterAtTime( v->TimeFree() );
|
DrawAddress( ptr+i );
|
||||||
|
if( ImGui::IsItemClicked() )
|
||||||
|
{
|
||||||
|
m_memoryAllocInfoWindow = arrIdx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( ImGui::IsItemClicked( 2 ) )
|
||||||
|
{
|
||||||
|
ZoomToRange( v->TimeAlloc(), v->TimeFree() >= 0 ? v->TimeFree() : m_worker.GetLastTime() );
|
||||||
|
}
|
||||||
|
if( ImGui::IsItemHovered() )
|
||||||
|
{
|
||||||
|
m_memoryAllocHover = arrIdx;
|
||||||
|
m_memoryAllocHoverWait = 2;
|
||||||
|
}
|
||||||
|
ImGui::NextColumn();
|
||||||
|
ImGui::TextUnformatted( MemSizeToString( v->Size() ) );
|
||||||
|
ImGui::NextColumn();
|
||||||
|
ImGui::PushID( idx++ );
|
||||||
|
if( ImGui::Selectable( TimeToString( v->TimeAlloc() - startTime ) ) )
|
||||||
|
{
|
||||||
|
CenterAtTime( v->TimeAlloc() );
|
||||||
}
|
}
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
if( v->ThreadAlloc() == v->ThreadFree() )
|
if( v->TimeFree() < 0 )
|
||||||
{
|
{
|
||||||
|
TextColoredUnformatted( ImVec4( 0.6f, 1.f, 0.6f, 1.f ), TimeToString( m_worker.GetLastTime() - v->TimeAlloc() ) );
|
||||||
|
ImGui::NextColumn();
|
||||||
const auto tid = m_worker.DecompressThread( v->ThreadAlloc() );
|
const auto tid = m_worker.DecompressThread( v->ThreadAlloc() );
|
||||||
SmallColorBox( GetThreadColor( tid, 0 ) );
|
SmallColorBox( GetThreadColor( tid, 0 ) );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -12678,114 +12665,130 @@ void View::ListMemData( T ptr, T end, std::function<void(T&)> DrawAddress, const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto tidAlloc = m_worker.DecompressThread( v->ThreadAlloc() );
|
ImGui::PushID( idx++ );
|
||||||
const auto tidFree = m_worker.DecompressThread( v->ThreadFree() );
|
if( ImGui::Selectable( TimeToString( v->TimeFree() - v->TimeAlloc() ) ) )
|
||||||
SmallColorBox( GetThreadColor( tidAlloc, 0 ) );
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::TextUnformatted( m_worker.GetThreadName( tidAlloc ) );
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::TextUnformatted( "/" );
|
|
||||||
ImGui::SameLine();
|
|
||||||
SmallColorBox( GetThreadColor( tidFree, 0 ) );
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::TextUnformatted( m_worker.GetThreadName( tidFree ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImGui::NextColumn();
|
|
||||||
auto zone = FindZoneAtTime( m_worker.DecompressThread( v->ThreadAlloc() ), v->TimeAlloc() );
|
|
||||||
if( !zone )
|
|
||||||
{
|
|
||||||
ImGui::TextUnformatted( "-" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const auto& srcloc = m_worker.GetSourceLocation( zone->SrcLoc() );
|
|
||||||
const auto txt = srcloc.name.active ? m_worker.GetString( srcloc.name ) : m_worker.GetString( srcloc.function );
|
|
||||||
ImGui::PushID( idx++ );
|
|
||||||
auto sel = ImGui::Selectable( txt, m_zoneInfoWindow == zone );
|
|
||||||
auto hover = ImGui::IsItemHovered();
|
|
||||||
ImGui::PopID();
|
|
||||||
if( sel )
|
|
||||||
{
|
|
||||||
ShowZoneInfo( *zone );
|
|
||||||
}
|
|
||||||
if( hover )
|
|
||||||
{
|
|
||||||
m_zoneHighlight = zone;
|
|
||||||
if( ImGui::IsMouseClicked( 2 ) )
|
|
||||||
{
|
{
|
||||||
ZoomToZone( *zone );
|
CenterAtTime( v->TimeFree() );
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
ImGui::NextColumn();
|
||||||
|
if( v->ThreadAlloc() == v->ThreadFree() )
|
||||||
|
{
|
||||||
|
const auto tid = m_worker.DecompressThread( v->ThreadAlloc() );
|
||||||
|
SmallColorBox( GetThreadColor( tid, 0 ) );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextUnformatted( m_worker.GetThreadName( tid ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto tidAlloc = m_worker.DecompressThread( v->ThreadAlloc() );
|
||||||
|
const auto tidFree = m_worker.DecompressThread( v->ThreadFree() );
|
||||||
|
SmallColorBox( GetThreadColor( tidAlloc, 0 ) );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextUnformatted( m_worker.GetThreadName( tidAlloc ) );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextUnformatted( "/" );
|
||||||
|
ImGui::SameLine();
|
||||||
|
SmallColorBox( GetThreadColor( tidFree, 0 ) );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextUnformatted( m_worker.GetThreadName( tidFree ) );
|
||||||
}
|
}
|
||||||
ZoneTooltip( *zone );
|
|
||||||
}
|
}
|
||||||
}
|
ImGui::NextColumn();
|
||||||
ImGui::NextColumn();
|
auto zone = FindZoneAtTime( m_worker.DecompressThread( v->ThreadAlloc() ), v->TimeAlloc() );
|
||||||
if( v->TimeFree() < 0 )
|
if( !zone )
|
||||||
{
|
|
||||||
TextColoredUnformatted( ImVec4( 0.6f, 1.f, 0.6f, 1.f ), "active" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto zoneFree = FindZoneAtTime( m_worker.DecompressThread( v->ThreadFree() ), v->TimeFree() );
|
|
||||||
if( !zoneFree )
|
|
||||||
{
|
{
|
||||||
ImGui::TextUnformatted( "-" );
|
ImGui::TextUnformatted( "-" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto& srcloc = m_worker.GetSourceLocation( zoneFree->SrcLoc() );
|
const auto& srcloc = m_worker.GetSourceLocation( zone->SrcLoc() );
|
||||||
const auto txt = srcloc.name.active ? m_worker.GetString( srcloc.name ) : m_worker.GetString( srcloc.function );
|
const auto txt = srcloc.name.active ? m_worker.GetString( srcloc.name ) : m_worker.GetString( srcloc.function );
|
||||||
ImGui::PushID( idx++ );
|
ImGui::PushID( idx++ );
|
||||||
bool sel;
|
auto sel = ImGui::Selectable( txt, m_zoneInfoWindow == zone );
|
||||||
if( zoneFree == zone )
|
|
||||||
{
|
|
||||||
ImGui::PushStyleColor( ImGuiCol_Text, ImVec4( 1.f, 1.f, 0.6f, 1.f ) );
|
|
||||||
sel = ImGui::Selectable( txt, m_zoneInfoWindow == zoneFree );
|
|
||||||
ImGui::PopStyleColor( 1 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sel = ImGui::Selectable( txt, m_zoneInfoWindow == zoneFree );
|
|
||||||
}
|
|
||||||
auto hover = ImGui::IsItemHovered();
|
auto hover = ImGui::IsItemHovered();
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
if( sel )
|
if( sel )
|
||||||
{
|
{
|
||||||
ShowZoneInfo( *zoneFree );
|
ShowZoneInfo( *zone );
|
||||||
}
|
}
|
||||||
if( hover )
|
if( hover )
|
||||||
{
|
{
|
||||||
m_zoneHighlight = zoneFree;
|
m_zoneHighlight = zone;
|
||||||
if( ImGui::IsMouseClicked( 2 ) )
|
if( ImGui::IsMouseClicked( 2 ) )
|
||||||
{
|
{
|
||||||
ZoomToZone( *zoneFree );
|
ZoomToZone( *zone );
|
||||||
}
|
}
|
||||||
ZoneTooltip( *zoneFree );
|
ZoneTooltip( *zone );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ImGui::NextColumn();
|
||||||
|
if( v->TimeFree() < 0 )
|
||||||
|
{
|
||||||
|
TextColoredUnformatted( ImVec4( 0.6f, 1.f, 0.6f, 1.f ), "active" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto zoneFree = FindZoneAtTime( m_worker.DecompressThread( v->ThreadFree() ), v->TimeFree() );
|
||||||
|
if( !zoneFree )
|
||||||
|
{
|
||||||
|
ImGui::TextUnformatted( "-" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto& srcloc = m_worker.GetSourceLocation( zoneFree->SrcLoc() );
|
||||||
|
const auto txt = srcloc.name.active ? m_worker.GetString( srcloc.name ) : m_worker.GetString( srcloc.function );
|
||||||
|
ImGui::PushID( idx++ );
|
||||||
|
bool sel;
|
||||||
|
if( zoneFree == zone )
|
||||||
|
{
|
||||||
|
ImGui::PushStyleColor( ImGuiCol_Text, ImVec4( 1.f, 1.f, 0.6f, 1.f ) );
|
||||||
|
sel = ImGui::Selectable( txt, m_zoneInfoWindow == zoneFree );
|
||||||
|
ImGui::PopStyleColor( 1 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sel = ImGui::Selectable( txt, m_zoneInfoWindow == zoneFree );
|
||||||
|
}
|
||||||
|
auto hover = ImGui::IsItemHovered();
|
||||||
|
ImGui::PopID();
|
||||||
|
if( sel )
|
||||||
|
{
|
||||||
|
ShowZoneInfo( *zoneFree );
|
||||||
|
}
|
||||||
|
if( hover )
|
||||||
|
{
|
||||||
|
m_zoneHighlight = zoneFree;
|
||||||
|
if( ImGui::IsMouseClicked( 2 ) )
|
||||||
|
{
|
||||||
|
ZoomToZone( *zoneFree );
|
||||||
|
}
|
||||||
|
ZoneTooltip( *zoneFree );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::NextColumn();
|
||||||
|
if( v->CsAlloc() == 0 )
|
||||||
|
{
|
||||||
|
TextDisabledUnformatted( "[alloc]" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SmallCallstackButton( "alloc", v->CsAlloc(), idx );
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Spacing();
|
||||||
|
ImGui::SameLine();
|
||||||
|
if( v->csFree.Val() == 0 )
|
||||||
|
{
|
||||||
|
TextDisabledUnformatted( "[free]" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SmallCallstackButton( "free", v->csFree.Val(), idx );
|
||||||
|
}
|
||||||
|
ImGui::NextColumn();
|
||||||
}
|
}
|
||||||
ImGui::NextColumn();
|
|
||||||
if( v->CsAlloc() == 0 )
|
|
||||||
{
|
|
||||||
TextDisabledUnformatted( "[alloc]" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SmallCallstackButton( "alloc", v->CsAlloc(), idx );
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Spacing();
|
|
||||||
ImGui::SameLine();
|
|
||||||
if( v->csFree.Val() == 0 )
|
|
||||||
{
|
|
||||||
TextDisabledUnformatted( "[free]" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SmallCallstackButton( "free", v->csFree.Val(), idx );
|
|
||||||
}
|
|
||||||
ImGui::NextColumn();
|
|
||||||
ptr++;
|
|
||||||
}
|
}
|
||||||
ImGui::EndColumns();
|
ImGui::EndColumns();
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
@ -13232,7 +13235,7 @@ void View::DrawMemory()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ListMemData<decltype( match.begin() )>( match.begin(), match.end(), [this]( auto& it ) {
|
ListMemData<decltype( match.begin() )>( match.begin(), match.end(), [this]( auto it ) {
|
||||||
auto& v = *it;
|
auto& v = *it;
|
||||||
if( v->Ptr() == m_memInfo.ptrFind )
|
if( v->Ptr() == m_memInfo.ptrFind )
|
||||||
{
|
{
|
||||||
@ -13289,7 +13292,7 @@ void View::DrawMemory()
|
|||||||
|
|
||||||
if( !items.empty() )
|
if( !items.empty() )
|
||||||
{
|
{
|
||||||
ListMemData<decltype( items.begin() )>( items.begin(), items.end(), []( auto& v ) {
|
ListMemData<decltype( items.begin() )>( items.begin(), items.end(), []( auto v ) {
|
||||||
ImGui::Text( "0x%" PRIx64, (*v)->Ptr() );
|
ImGui::Text( "0x%" PRIx64, (*v)->Ptr() );
|
||||||
}, "##activeMem" );
|
}, "##activeMem" );
|
||||||
}
|
}
|
||||||
@ -13559,7 +13562,7 @@ void View::DrawAllocList()
|
|||||||
ImGui::SetNextWindowSize( ImVec2( 1100, 500 ), ImGuiCond_FirstUseEver );
|
ImGui::SetNextWindowSize( ImVec2( 1100, 500 ), ImGuiCond_FirstUseEver );
|
||||||
ImGui::Begin( "Allocations list", &m_memInfo.showAllocList );
|
ImGui::Begin( "Allocations list", &m_memInfo.showAllocList );
|
||||||
TextFocused( "Number of allocations:", RealToString( m_memInfo.allocList.size() ) );
|
TextFocused( "Number of allocations:", RealToString( m_memInfo.allocList.size() ) );
|
||||||
ListMemData<decltype( data.begin() )>( data.begin(), data.end(), []( auto& v ) {
|
ListMemData<decltype( data.begin() )>( data.begin(), data.end(), []( auto v ) {
|
||||||
ImGui::Text( "0x%" PRIx64, (*v)->Ptr() );
|
ImGui::Text( "0x%" PRIx64, (*v)->Ptr() );
|
||||||
}, "##allocations" );
|
}, "##allocations" );
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
@ -154,7 +154,7 @@ private:
|
|||||||
void DrawAnnotationList();
|
void DrawAnnotationList();
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void ListMemData( T ptr, T end, std::function<void(T&)> DrawAddress, const char* id = nullptr, int64_t startTime = -1 );
|
void ListMemData( T ptr, T end, std::function<void(T)> DrawAddress, const char* id = nullptr, int64_t startTime = -1 );
|
||||||
|
|
||||||
unordered_flat_map<uint32_t, PathData> GetCallstackPaths( const MemData& mem, bool onlyActive ) const;
|
unordered_flat_map<uint32_t, PathData> GetCallstackPaths( const MemData& mem, bool onlyActive ) const;
|
||||||
unordered_flat_map<uint64_t, CallstackFrameTree> GetCallstackFrameTreeBottomUp( const MemData& mem ) const;
|
unordered_flat_map<uint64_t, CallstackFrameTree> GetCallstackFrameTreeBottomUp( const MemData& mem ) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user