I am pretty new to Odin an am writing compiler as a learning project. I came to a problem with memory leak warnings that I cannot solve. In the image is one of the procedures where the memory leak happens, specifically in strings.clone() line. But I don't know how to solve this because I cannot just defer delete this string. I am thinking either the whole code structure is not correct or I need to use some memory stuff like allocators?
#Memory leak
1 messages · Page 1 of 1 (latest)
The general structure is fine, that just means whoever calls the proc needs to delete the string when they're done with it
so i need to delete it in test method? But this is 3 procedures deep
It has to be deleted somewhere. The alternative would be to use a temporary allocator (e.g. context.temp_allocator) so that you can free everything allocated with that allocator at once without needing to do it individually (free_all(context.temp_allocator)). That also works for tests, it won't complain about things in the temp_allocator
if the file has a long enough lifetime you could also just store a slice instead of cloning it