Out-of-memory on 32-bit #78

Open
opened 2022-03-28 00:52:56 +00:00 by kirsle · 0 comments

Noticed in v0.12.0 release.

Azulian Tag - Forest is hard to complete on 32-bit builds (Windows esp.) without running out of memory (SDL2 texture deallocation, likely).

Ideas to improve:

  • Add a Level.Teardown() function for the game to call whenever a level is going away (not between play/edit but when loading a diff level or closing out completely), Teardown() should have the Chunker free all SDL2 textures so at least we don't have more than a level's worth of chunks loaded at once.
  • During gameplay the level chunker could more proactively load/unload textures.
    • Currently the loadscreen precomputes Go images for every chunk, this is probably OK.
    • When chunks scroll on screen it turns the Go images into SDL textures.
    • New: when chunks leave the screen far enough, unload the SDL textures?

Improvements made:

  • Free SDL2 textures more proactively in db5760ee83

Azulian Tag still loads about 1.5 GB into memory, maybe the precomputed Go images are still too heavy, ideas to try next:

  • Only load Go images for chunks in the viewport. (Make a slightly wider viewport and call it the "loading viewport" to be a couple chunks outside the screen edges, and the loadscreen only loads these images instead of the whole level)
  • As the level scrolls and the loading viewport changes, new chunks entering the viewport will compute their Go images.
  • Chunks that leave the viewport can unload their Go images and free their SDL textures immediately.
  • Goroutines may be able to parallelize the chunk loading to avoid lagging the main thread.
Noticed in v0.12.0 release. Azulian Tag - Forest is hard to complete on 32-bit builds (Windows esp.) without running out of memory (SDL2 texture deallocation, likely). Ideas to improve: * Add a Level.Teardown() function for the game to call whenever a level is going away (not between play/edit but when loading a diff level or closing out completely), Teardown() should have the Chunker free all SDL2 textures so at least we don't have more than a level's worth of chunks loaded at once. * During gameplay the level chunker could more proactively load/unload textures. * Currently the loadscreen precomputes Go images for every chunk, this is probably OK. * When chunks scroll on screen it turns the Go images into SDL textures. * **New:** when chunks leave the screen far enough, unload the SDL textures? --- Improvements made: * Free SDL2 textures more proactively in https://git.kirsle.net/apps/doodle/commit/db5760ee83f2d3e62a90f9a0b9f48e8c33fecb2b Azulian Tag still loads about 1.5 GB into memory, maybe the precomputed Go images are still too heavy, ideas to try next: * Only load Go images for chunks in the viewport. (Make a slightly wider viewport and call it the "loading viewport" to be a couple chunks outside the screen edges, and the loadscreen only loads these images instead of the whole level) * As the level scrolls and the loading viewport changes, new chunks entering the viewport will compute their Go images. * Chunks that leave the viewport can unload their Go images and free their SDL textures immediately. * Goroutines may be able to parallelize the chunk loading to avoid lagging the main thread.
kirsle added the
bug
label 2022-03-28 00:52:56 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: SketchyMaze/doodle#78
There is no content yet.