Odin tracker for detecting leaks and bad frees of memory allocated using the context.allocator. Output is colorized and table formatted.
Full credit to Odin (gingerbill) and Karl Zylinski for the original version of the non-formatted version.
This package depends on afmt package.
Requires Odin version 2026-03 or later. See moving-towards-a-new-core-os
Check out Ginger Bill’s Memory Allocation Strategy series for tips on memory management.
- Using the terminal, navigate to odin/shared folder and clone with
# Option 1 - put tracker and afmt in default shared collection folder inside Odin root folder cd $(odin root)shared # Option 2 - put tracker and afmt folders in project source root folder cd <project source root folder> # Then clone both packages git clone https://github.com/OnlyXuul/tracker.git git clone https://github.com/OnlyXuul/afmt.git
- Update files
// Option 1 - tracker and afmt are in default shared collection folder inside Odin root folder // Add to your project import "shared:tracker" // Option 2 - tracker and afmt folders are in project source root folder // Add to your project import "tracker" // Change afmt import in tracker/tracker.odin import "../afmt"
- Copy into your project:
// Option 1 - Most used // Non-Global - Benefits from main() as the originating scope for everything else after // Copy-Paste this to top of main in your project when ODIN_DEBUG { //tracker.NOPANIC = true // uncomment or override with: -define:nopanic=true t := tracker.init() context.allocator = t.allocator defer tracker.print_and_destroy(&t) } // Option 2 - Useful when procedures do not originate from the same scope (i.e. no main procedure) // Global Tracker - 3 parts // Part 1 - Copy-Paste this to beginning of init() procedure like in wasm when ODIN_DEBUG { //tracker.NOPANIC = true // uncomment or override with: -define:nopanic=true tracker.init_global() context.allocator = tracker.global.allocator } // Part 2 - Copy and paste this to the beginning of every procedure you wish tracker to collect data for when ODIN_DEBUG { context.allocator = tracker.global.allocator } // Part 3 - Copy and past this to beginning of final procedure like shutdown() in wasm when ODIN_DEBUG { context.allocator = tracker.global.allocator defer tracker.print_and_destroy(&tracker.global) }
- Build your project with:
By default, the tracker will panic on bad frees. To override this use:odin build . -debug
By default, the tracker will use ansi color and attribute formatting. To override this use:odin build . -debug -define:nopanic=true
odin build . -debug -define:noansi=true
cd <tracker folder>
cd example
odin run . -debug -define:nopanic=trueodin build . -debug -define:nopanic=true
odin build . -debug -define:nopanic=true