I’ve been fixing memory leaks in a couple of projects of mine, using the memory tracking allocator as described in chapter 13 of Karl Zylinski’s Understanding the Odin Programming Language (by the way, I have used Odin for two years, for hobby projects, and buying this book was totally worth, especially the chapter on manual memory management).
Well, I fixed all of the leaks reported in my code, mostly caused by string operations. My problem is some leaks are still reported, but only their origin in the core lib is mentioned:
1 leaks:
/opt/Odin-dev-2025-01/core/strings/builder.odin(171:11) leaked 185 bytes
No bad `free`
15 leaks:
/opt/Odin-dev-2025-01/core/strings/builder.odin(171:11) leaked 184 bytes
/opt/Odin-dev-2025-01/core/strings/conversion.odin(106:2) leaked 1 bytes
/opt/Odin-dev-2025-01/core/strings/conversion.odin(106:2) leaked 2 bytes
/opt/Odin-dev-2025-01/core/strings/conversion.odin(106:2) leaked 3 bytes
/opt/Odin-dev-2025-01/core/strings/conversion.odin(106:2) leaked 7 bytes
/opt/Odin-dev-2025-01/core/strings/conversion.odin(141:2) leaked 1 bytes
/opt/Odin-dev-2025-01/core/strings/strings.odin(3037:10) leaked 14 bytes
/opt/Odin-dev-2025-01/core/strings/strings.odin(3037:10) leaked 2 bytes
/opt/Odin-dev-2025-01/core/strings/strings.odin(3037:10) leaked 2 bytes
/opt/Odin-dev-2025-01/core/strings/strings.odin(3037:10) leaked 2 bytes
/opt/Odin-dev-2025-01/core/strings/strings.odin(3045:2) leaked 14 bytes
/opt/Odin-dev-2025-01/core/strings/strings.odin(3045:2) leaked 14 bytes
/opt/Odin-dev-2025-01/core/strings/strings.odin(3045:2) leaked 14 bytes
/opt/Odin-dev-2025-01/core/strings/strings.odin(3045:2) leaked 15 bytes
/opt/Odin-dev-2025-01/core/strings/strings.odin(3045:2) leaked 16 bytes
No bad `free`
To add some context to the issue, both projects are text-based games and relatively small:
github.com/AlDanial/cloc v 1.96 T=0.02 s (1165.9 files/s, 200300.2 lines/s)
Language files blank comment code
Odin 24 1036 575 2512
github.com/AlDanial/cloc v 1.96 T=0.07 s (382.3 files/s, 157266.9 lines/s)
Language files blank comment code
Odin 25 2066 1422 6796
Using the reported lines of the core lib, I’ve been trying to find out which operations in my code cause the leaks. I have added check points and debugging code and made many tests, but so far I have no clue.
Any advice will be appreciated.