Skip to content

Latest commit

 

History

History
61 lines (54 loc) · 1.83 KB

File metadata and controls

61 lines (54 loc) · 1.83 KB

Tracker

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.

Steps

  1. 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
  2. Add to your project

    import "shared:tracker"
  3. 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)
    }
  4. Build with:

    odin build . -debug
    

    By default, the tracker will panic on bad frees. To override this use:

    odin build . -debug -define:nopanic=true
    

    By default, the tracker will use ansi color and attribute formatting. To override this use:

    odin build . -debug -define:noansi=true
    

Run example.odin

cd $(odin root)shared/tracker/example
odin run . -debug -define:nopanic=true

Example Output

No Problems

odin build . -debug -define:nopanic=true

Alt text

Problems Found

odin build . -debug -define:nopanic=true

Alt text