Nothing closes the registry's fonts at teardown, and there is no akgl_game_shutdown #15

Open
opened 2026-08-02 18:32:55 -04:00 by tachikoma · 0 comments
Collaborator

Source: TODO.md, "Defects the memory checker found", item 38 (at bbb7b8f)

A font costs 10,523 bytes -- 736 of them SDL_ttf's, the rest FreeType's.

akgl_text_unloadfont(char *name) and akgl_text_unloadallfonts(void) both exist
(include/akgl/text.h:89), so the API gap that used to be here is closed: a game
that switches fonts between scenes can give the old one back, and
akgl_text_loadfont calls unload itself when it replaces a live name.

What is missing is the teardown that calls them. There is no
akgl_game_shutdown, so a game that exits without unloading leaks every font it
loaded exactly once. Valgrind reports that against the process rather than against
a loop, which is why it is bounded and low-urgency -- but the natural home for it
does not exist, and akgl_game_init has no counterpart at all.

Scope worth deciding when this is picked up: a shutdown entry point is the obvious
home for more than fonts (the mixer, the tracks, the registries, SDL_Quit), and
that is a bigger contract than "close the fonts".

Files: src/game.c, src/text.c:76, include/akgl/game.h


Filed by Tachikoma (Claude Code, Opus 5, 1M context)

**Source:** TODO.md, "Defects the memory checker found", item 38 (at bbb7b8f) A font costs 10,523 bytes -- 736 of them SDL_ttf's, the rest FreeType's. `akgl_text_unloadfont(char *name)` and `akgl_text_unloadallfonts(void)` both exist (`include/akgl/text.h:89`), so the API gap that used to be here is closed: a game that switches fonts between scenes can give the old one back, and `akgl_text_loadfont` calls unload itself when it replaces a live name. **What is missing is the teardown that calls them.** There is no `akgl_game_shutdown`, so a game that exits without unloading leaks every font it loaded exactly once. Valgrind reports that against the process rather than against a loop, which is why it is bounded and low-urgency -- but the natural home for it does not exist, and `akgl_game_init` has no counterpart at all. Scope worth deciding when this is picked up: a shutdown entry point is the obvious home for more than fonts (the mixer, the tracks, the registries, `SDL_Quit`), and that is a bigger contract than "close the fonts". **Files:** `src/game.c`, `src/text.c:76`, `include/akgl/game.h` --- Filed by Tachikoma (Claude Code, Opus 5, 1M context)
tachikoma added this to the 0.10.0 milestone 2026-08-02 18:32:55 -04:00
tachikoma added the api-gapblast-radius:medium labels 2026-08-02 18:32:55 -04:00
tachikoma added the status::grooming label 2026-08-02 18:49:13 -04:00
Sign in to join this conversation.