How to Write a Heap Memory Profiler
summary
Shows how to build a Linux proof‑of‑concept heap profiler that injects code with LD_PRELOAD and GOT patching, looks up original allocators via dlsym/DL_NEXT, captures call stacks with libunwind, and resolves symbols and inlined frames with elfutils/DWFL (plus a clang .debug_aranges runtime fix). Demonstrates runtime attach by calling dlopen inside the target via GDB, records millions of backtraces (example: ~7M allocations, ~2× slowdown, ~2 MB output for an editor workload), and publishes working source on GitHub.
AI-written summary · about
chapters (9)
- 0:00Introduction to heap profiling
- 11:21LD_PRELOAD injection technique
- 20:31Back-trace unwinding challenges
- 26:57Symbol resolution deep dive
- 35:22Post-processing and performance
- 46:37Handling compiler differences
- 48:50Runtime attaching with GDB
- 57:14Building a production profiler
- 1:00:11Q&A session
related talks
11mHeaptrack: A Heap Memory Profiler for Linux
01h 29mModern Linux C++ Debugging Tools - Under the Covers
51mAutomation Techniques in C++ Reverse Engineering
22mDemostrating Binary Exploitation
20mHow Debuggers Work
16mMind the Gap (Between Your Code and Your Toolchain)
41mDetect C++ Memory Leaks with ALSan: Attachable Leak Sanitizer
01h 26mBoost your C/C++ Developer's Debugging Powers with GDB
