Debug: add debug messages for memory leaks

This commit is contained in:
Francesco Abbate 2021-03-16 11:06:51 +01:00
parent 8ace5f6f77
commit 6893cd7e29
3 changed files with 7 additions and 0 deletions

View File

@ -860,6 +860,9 @@ function core.run()
-- do not wait of events at idle_iterations = 1 to give a chance at core.step to run -- do not wait of events at idle_iterations = 1 to give a chance at core.step to run
-- and set "redraw" flag. -- and set "redraw" flag.
if idle_iterations > 1 then if idle_iterations > 1 then
collectgarbage()
local mk, mb = collectgarbage("count")
io.stderr:write(string.format("memory usage %g \r", mk))
if system.window_has_focus() then if system.window_has_focus() then
-- keep running even with no events to make the cursor blinks -- keep running even with no events to make the cursor blinks
system.wait_event(frame_duration) system.wait_event(frame_duration)

View File

@ -168,5 +168,7 @@ init_lua:
SDL_DestroyWindow(window); SDL_DestroyWindow(window);
SDL_Quit(); SDL_Quit();
fprintf(stderr, "complete shutdown\n");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -157,10 +157,12 @@ void ren_free_font(RenFont *font) {
for (int i = 0; i < MAX_GLYPHSET; i++) { for (int i = 0; i < MAX_GLYPHSET; i++) {
GlyphSet *set = font->sets[i]; GlyphSet *set = font->sets[i];
if (set) { if (set) {
fprintf(stderr, "free font bitmap: %d\n", i);
FR_Bitmap_Free(set->image); FR_Bitmap_Free(set->image);
free(set); free(set);
} }
} }
fprintf(stderr, "free font renderer\n");
FR_Renderer_Free(font->renderer); FR_Renderer_Free(font->renderer);
free(font); free(font);
} }