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.
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
cd $(odin root)shared git clone https://github.com/OnlyXuul/tracker.git git clone https://github.com/OnlyXuul/afmt.git
-
Add to your project
import "shared:tracker"
-
Copy to the top of main procedure in your project:
when ODIN_DEBUG { //tracker.NOPANIC = true // uncomment or override with: -define:nopanic=true t := tracker.init_tracker() context.allocator = tracker.tracking_allocator(&t) defer tracker.print_and_destroy_tracker(&t) }
-
Build with:
odin build . -debugBy default, the tracker will panic on bad frees. To override this use:
odin build . -debug -define:nopanic=trueBy default, the tracker will use ansi color and attribute formatting. To override this use:
odin build . -debug -define:noansi=true
cd $(odin root)shared/tracker/example
odin run . -debug -define:nopanic=trueodin build . -debug -define:nopanic=true
odin build . -debug -define:nopanic=true