clean up memory after the game is done

This commit is contained in:
2026-06-14 00:02:16 -07:00
parent 042fc9fe62
commit 7d25c20110
2 changed files with 21 additions and 0 deletions
+5
View File
@@ -20,5 +20,10 @@ run :: proc() {
render_world(&world)
rl.EndDrawing()
}
delete(world.path)
delete(world.towers)
delete(world.events)
}
+16
View File
@@ -1,8 +1,24 @@
package main
import game "./game"
import "core:fmt"
import "core:mem"
main :: proc() {
track: mem.Tracking_Allocator
mem.tracking_allocator_init(&track, context.allocator)
defer mem.tracking_allocator_destroy(&track)
context.allocator = mem.tracking_allocator(&track)
game.run()
// Report at exit
fmt.printf("peak heap: %d bytes\n", track.peak_memory_allocated)
fmt.printf("still live: %d bytes\n", track.current_memory_allocated)
for _, leak in track.allocation_map {
fmt.printf("leak at %v: %m\n", leak.location, leak.size)
}
}