[perf] Per-image dedicated alloc + leaked persistent staging buffer (ImageVulkan.cppm) #114

Closed
opened 2026-06-17 21:18:52 +02:00 by jorijnvdgraaf · 0 comments

Found by an adversarially-verified performance audit (confirmed real after a skeptic pass).

Location: interfaces/Crafter.Graphics-ImageVulkan.cppm:99-131
Severity: high · Effort: moderate · Category: memory

Problem

Each texture allocates a dedicated image VkDeviceMemory (:130) plus a persistent HOST_VISIBLE staging buffer (:99) sized w*h, kept mapped for the image lifetime — and Destroy() never frees buffer, so it leaks. Static textures (e.g. Sponza albedo, uploaded once) pin host-visible / small-BAR memory forever.

Fix

DeferredClear the staging buffer after the copy (as the compressed path already does at :313), gated by a streamed flag so FontAtlas keeps its persistent staging. Optionally back image memory from the same suballocator (larger, lower priority).

Found by an adversarially-verified performance audit (confirmed real after a skeptic pass). **Location:** `interfaces/Crafter.Graphics-ImageVulkan.cppm:99-131` **Severity:** high · **Effort:** moderate · **Category:** memory ### Problem Each texture allocates a dedicated image `VkDeviceMemory` (`:130`) **plus** a persistent HOST_VISIBLE staging `buffer` (`:99`) sized `w*h`, kept mapped for the image lifetime — and `Destroy()` never frees `buffer`, so it leaks. Static textures (e.g. Sponza albedo, uploaded once) pin host-visible / small-BAR memory forever. ### Fix `DeferredClear` the staging buffer after the copy (as the compressed path already does at `:313`), gated by a `streamed` flag so FontAtlas keeps its persistent staging. Optionally back image memory from the same suballocator (larger, lower priority).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
Catcrafts/Crafter.Graphics#114
No description provided.