From a51bb8c7388c7bd0a97e3ad8ff91a084c4bfdb88 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 31 Oct 2026 14:46:51 +0100 Subject: [PATCH] Add a memory pools achievement. --- profiler/CMakeLists.txt | 1 + profiler/src/achievements/MemoryPools.md | 7 +++++++ profiler/src/profiler/TracyAchievementData.cpp | 9 ++++++++- profiler/src/profiler/TracyView_Memory.cpp | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 profiler/src/achievements/MemoryPools.md diff --git a/profiler/CMakeLists.txt b/profiler/CMakeLists.txt index 25607bb0..5868442e 100644 --- a/profiler/CMakeLists.txt +++ b/profiler/CMakeLists.txt @@ -227,6 +227,7 @@ Embed(PROFILER_FILES TextLoadTrace src/achievements/LoadTrace.md TEXT) Embed(PROFILER_FILES TextLocks src/achievements/Locks.md TEXT) Embed(PROFILER_FILES TextManual src/achievements/Manual.md TEXT) Embed(PROFILER_FILES TextMemory src/achievements/Memory.md TEXT) +Embed(PROFILER_FILES TextMemoryPools src/achievements/MemoryPools.md TEXT) Embed(PROFILER_FILES TextNameThreads src/achievements/NameThreads.md TEXT) Embed(PROFILER_FILES TextLightFlame src/achievements/LightFlame.md TEXT) Embed(PROFILER_FILES TextPlots src/achievements/Plots.md TEXT) diff --git a/profiler/src/achievements/MemoryPools.md b/profiler/src/achievements/MemoryPools.md new file mode 100644 index 00000000..59672fe5 --- /dev/null +++ b/profiler/src/achievements/MemoryPools.md @@ -0,0 +1,7 @@ +# Separate pools + +An application rarely allocates from a single heap: the C runtime provides `malloc`, a graphics API manages device memory on its own, and a script VM runs its allocator. Report all of it through plain `TracyAlloc` and the usage curve is a single total that hides which heap is which. + +[`TracyAllocN( ptr, size, name )` and `TracyFreeN( ptr, name )`](#memorypools) attribute events to the pool named by `name`, a [unique pointer to a string literal](#uniquepointers) like every other Tracy string. Every pool gets its own usage plot above the timeline, and once a second pool shows up the [Memory window](#memorywindow) grows a * Memory pool* selector, so its lists, memory map and call stack trees describe that pool alone. + +Switch to your named pool and see what it holds. Try it out! diff --git a/profiler/src/profiler/TracyAchievementData.cpp b/profiler/src/profiler/TracyAchievementData.cpp index 1f495541..4838b551 100644 --- a/profiler/src/profiler/TracyAchievementData.cpp +++ b/profiler/src/profiler/TracyAchievementData.cpp @@ -25,6 +25,7 @@ #include "data/TextLocks.hpp" #include "data/TextManual.hpp" #include "data/TextMemory.hpp" +#include "data/TextMemoryPools.hpp" #include "data/TextNameThreads.hpp" #include "data/TextPlots.hpp" #include "data/TextReadAssembly.hpp" @@ -77,7 +78,13 @@ AchievementItem ai_allocStacks = { .text = Unpack( TextAllocStacks ) }; -AchievementItem* ac_trackMemoryItems[] = { &ai_huntLeaks, &ai_allocStacks, nullptr }; +AchievementItem ai_memoryPools = { + .id = "memoryPools", + .name = "Separate pools", + .text = Unpack( TextMemoryPools ) +}; + +AchievementItem* ac_trackMemoryItems[] = { &ai_huntLeaks, &ai_allocStacks, &ai_memoryPools, nullptr }; AchievementItem ai_trackMemory = { .id = "trackMemory", diff --git a/profiler/src/profiler/TracyView_Memory.cpp b/profiler/src/profiler/TracyView_Memory.cpp index 10ca7a7a..65819158 100644 --- a/profiler/src/profiler/TracyView_Memory.cpp +++ b/profiler/src/profiler/TracyView_Memory.cpp @@ -191,6 +191,7 @@ void View::DrawMemory() { if( ImGui::Selectable( v.first == 0 ? "Default allocator" : m_worker.GetString( v.first ) ) ) { + if( s_config.achievements && v.first != 0 ) Achieve( "memoryPools" ); m_memInfo.pool = v.first; m_memInfo.showAllocList = false; }