clean up memory after the game is done
This commit is contained in:
@@ -20,5 +20,10 @@ run :: proc() {
|
||||
render_world(&world)
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
delete(world.path)
|
||||
delete(world.towers)
|
||||
delete(world.events)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user