Skip to content

Vulkan: release command buffer memory at each begin on Arm's driver (memory leak) - #607

Merged
peiikai merged 1 commit into
peiikai:beta_6from
wolfchimneyrock:mali-cb-release
Nov 7, 2026
Merged

peiikai merged 1 commit into
peiikai:beta_6from
wolfchimneyrock:mali-cb-release

Conversation

@wolfchimneyrock

Copy link
Copy Markdown

On Arm's own Vulkan driver (libmali) the game's memory grows by about 490 MB an hour, until it runs out of memory after a few hours (sooner on 4 GB boards). PanVK and Turnip don't grow.

Cause. A malloc tracker on the running game put every growing allocation inside libmali: 64 KB host-memory blocks allocated by vkCmdBeginRendering (about 95% from begin_pass, the rest from vk_frame_begin). The command buffers are reused through the implicit reset of vkBeginCommandBuffer (pool flag RESET_COMMAND_BUFFER), and libmali keeps those blocks across that reset.

Change. Before each begin, begin_cb_run resets the command buffer with VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT. On by default for VK_DRIVER_ID_ARM_PROPRIETARY only; LARECOMP_VK_CB_RELEASE=0/1 overrides, logged at start like the other per-GPU defaults; a row in docs/vulkan-gpu-defaults.md.

Tested (Vulkan backend only; nothing changes on Metal): Linux, RK3588 (Mali-G610), libmali g29p1, 720p, the Field east of Marin and Tarin's house, 7-minute runs, warm shader cache:

libmali's block site, 60 s → 420 s all live malloc, 60 s → 420 s frame time GPU time
LARECOMP_VK_CB_RELEASE=0 15 → 57 MB 277 → 259 MB, rising 7 MB/min from 120 s 33.41 ms 16.02 ms
default (on) 9 → 8 MB 180 → 200 MB, flat from 120 s 33.43 ms 16.05 ms

The same change on an earlier build held flat for 7 minutes too. PanVK (Mesa main) and Turnip were already flat and keep the old path.

🤖 Generated with Claude Code

libmali keeps the memory vkCmdBeginRendering allocates across the implicit
reset of vkBeginCommandBuffer, so the process grew by ~490 MB an hour.
Reset with RELEASE_RESOURCES before each begin on VK_DRIVER_ID_ARM_PROPRIETARY;
LARECOMP_VK_CB_RELEASE=0/1 overrides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@peiikai
peiikai merged commit 0c36111 into peiikai:beta_6 Nov 7, 2026
5 checks passed
@peiikai

peiikai commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Thanks, merged into beta_6 in 0c36111. On Arm's driver the command buffers now give their memory back at each begin, so the game no longer grows until it runs out; it goes live with the next release.

peiikai added a commit that referenced this pull request Nov 7, 2026
README: credit wolfchimneyrock for #607
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants