Add an allocation call stacks achievement.

This commit is contained in:
Bartosz Taudul
2026-10-31 18:13:32 +01:00
parent 97d9368741
commit a4595ee85d
4 changed files with 18 additions and 1 deletions
+1
View File
@@ -206,6 +206,7 @@ add_custom_command(
Embed(PROFILER_FILES Manual manual/tracy.md TEXT BUILD)
Embed(PROFILER_FILES Text100Million src/achievements/100Million.md TEXT)
Embed(PROFILER_FILES TextAllocStacks src/achievements/AllocStacks.md TEXT)
Embed(PROFILER_FILES TextAnnotateZones src/achievements/AnnotateZones.md TEXT)
Embed(PROFILER_FILES TextAppInfo src/achievements/AppInfo.md TEXT)
Embed(PROFILER_FILES TextConnectToClient src/achievements/ConnectToClient.md TEXT)
+7
View File
@@ -0,0 +1,7 @@
# Trace allocation call stacks
The allocation lists tell you what is in memory, but not who put it there. Swap the macros for their [S-postfix](#collectingcallstacks) variants, `TracyAllocS( ptr, size, depth )` and `TracyFreeS( ptr, depth )`, and every event carries a call stack. Capturing a stack costs time, and the cost grows with `depth`.
When the events carry stacks, the [Memory window](#memorywindow) can group them into trees. The * Top-down call stack tree* starts at the allocating functions and expands the call paths that led there, each level sorted by the bytes allocated in its branch, so the hottest allocators sit at the top. The bottom-up pane walks the same data the other way, from the call stack entry point down to the allocation site. Right-click a function name to list the [allocations](#alloclist) behind it.
Expand the top-down tree and follow the top branch. Try it out!
@@ -2,6 +2,7 @@
#include "TracyEmbed.hpp"
#include "data/Text100Million.hpp"
#include "data/TextAllocStacks.hpp"
#include "data/TextAnnotateZones.hpp"
#include "data/TextAppInfo.hpp"
#include "data/TextCompareTraces.hpp"
@@ -70,7 +71,13 @@ AchievementItem ai_huntLeaks = {
.text = Unpack( TextLeaks )
};
AchievementItem* ac_trackMemoryItems[] = { &ai_huntLeaks, nullptr };
AchievementItem ai_allocStacks = {
.id = "allocStacks",
.name = "Trace allocation call stacks",
.text = Unpack( TextAllocStacks )
};
AchievementItem* ac_trackMemoryItems[] = { &ai_huntLeaks, &ai_allocStacks, nullptr };
AchievementItem ai_trackMemory = {
.id = "trackMemory",
@@ -466,6 +466,7 @@ void View::DrawMemory()
auto tree = GetCallstackFrameTreeBottomUp( mem );
if( !tree.empty() )
{
if( s_config.achievements ) Achieve( "allocStacks" );
int idx = 0;
DrawFrameTreeLevel( tree, idx );
}
@@ -504,6 +505,7 @@ void View::DrawMemory()
auto tree = GetCallstackFrameTreeTopDown( mem );
if( !tree.empty() )
{
if( s_config.achievements ) Achieve( "allocStacks" );
int idx = 0;
DrawFrameTreeLevel( tree, idx );
}