Repository navigation
Jedi Knight: the largest arrays allocated at launch (+995 KB PSRAM in every other game), sizes in Kconfig - #34
Merged
Merged
Conversation
…(~1 MB less static PSRAM)
Every core's .bss is summed into static PSRAM, so Jedi Knight's 1.31 MB of
statics was reserved in every other game. The engine (OpenJKDF2 bump to
esp32/alloc-arrays-at-start) now keeps its largest arrays as pointers: jk.cpp
allocates them in one zeroed block from the engine heap right after the ROM
arena is set up, before the engine task starts (a launch without the memory
fails cleanly: the cart quits), and frees them in deinit() once the engine
and audio tasks are gone. Each launch gets fresh zeroed buffers.
- per launch (362 KB at the defaults): sithAI_actors, jkPlayer_playerInfos,
jkPlayer_otherThings, jkPlayer_aMotsInfos, aEntryStack,
sithCollision_aCollisions, sithSurface_aSurfaces, the port's directory
cache
- gone: the active-edge rasterizer pools (616 KB, unused with the z-buffered
rasterizer) and sithSound's bounce buffer (16 KB, unused on ESP32)
generated/globals.{c,h} declare the five moved globals as pointers under
PLATFORM_SESSION_ARRAYS, as the updated cog templates generate them.
Kconfig "Engine table sizes": AI actors (128), directory cache entries (512),
active-edge faces / spans (1024 / 2048, not allocated with the z-buffered
rasterizer), passed to the engine as compile definitions.
.ext_ram.bss: 2,197,512 -> 1,179,912 bytes; JK's share 1,338,411 -> 320,851.
overlay_image.py check 2c skips merged string sections (.str1.N): text holds
no addresses, and with the smaller .ext_ram.bss the overlay moved to where two
string words in esp_stdio's .rodata happened to fall (false positive).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
…zer sizes Review follow-ups to the per-launch engine arrays: - Kconfig: the "Active-edge rasterizer faces/spans" options are gone (and their -D lines): with RDRASTER_SW_ZBUFFER those pools are never allocated, so the options changed nothing. rdActive.h keeps its defaults. - Kconfig: new "Material (texture) cache" menu. The cache has no fixed size (it grows into free memory and evicts on allocation failure); its two real knobs are now options, passed to the engine as -D values: JK_MATERIAL_PURGE_FREE_KB (2560: evict unused materials while less than this is free; 0 turns it off) and JK_MATERIAL_PURGE_AGE_FRAMES (900). - jk.cpp (JK_ESP_DEBUG builds): the allocation dump says the session arrays block (jk_esp_arrays_bytes()) is among the live allocations until deinit() frees it, so it is not read as a leak. - CMakeLists: the static-state comment now says ~320 KB. - OpenJKDF2 6a5d1d96: the eviction knobs, and jkPlayer_Shutdown's MoTS loop frees its own polyline thing (it named jkPlayer_otherThings). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
This was referenced Nov 21, 2026
tools/overlay_image.py: both sides added the merged-strings exception (#30 and this branch); main's version is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
finger563
added a commit
that referenced
this pull request
Nov 21, 2026
The conflicts (jk.cpp, jk_esp.h, the OpenJKDF2 submodule) were #34's own changes against their squashed copy; this branch already contains them, so the result is this branch's tree (6a715074 contains 6a5d1d96). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Jedi Knight's largest arrays are allocated when it starts and freed when it quits, instead of sitting in static PSRAM while every other game runs. Every other game gets about 995 KB of PSRAM:
static PSRAM: 2.20 MB → 1.18 MB;
Jedi Knight's share: 1.34 MB → 321 KB;
GBA in game: 5,425 → 6,420 KB free.
Engine (esp-cpp/OpenJKDF2 esp32/alloc-arrays-at-start, ESP32: allocate the largest arrays per session, sizes from the build OpenJKDF2#1):
aBounce(16 KB) is dropped.components/jk/generated/globals.{c,h}: regenerated from the updated cog templates.jk.cpp:init()allocates the block right after the arena is created, so it's the arena's first allocation and can't fragment the level's data.deinit()frees it after the engine and audio tasks have stopped.Kconfig ("Engine table sizes", "Material (texture) cache"):
JK_SITHAI_MAX_ACTORS(128);JK_FS_DIR_CACHE_ENTRIES(512);JK_MATERIAL_PURGE_FREE_KB(2560);JK_MATERIAL_PURGE_AGE_FRAMES(900).overlay_image.py: the merged-strings fix from Launcher: the backdrop in 64 px tiles, smaller LVGL draw buffers (redraws 57 -> 41 ms, +184 KB in games) #30, which this change's new layout also needed. It's identical, so the two PRs merge cleanly.Testing (Tab5)
Merge esp-cpp/OpenJKDF2#1 first; this PR's submodule points at its branch.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY