-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Initially I noticed that the RAM usage of my program was growing ever so slightly (~0.5 MB/s).
But after hours of debugging my renderer, I think I may have found a leak in wgpu-hal.
I could reproduce the behavior in the official wgpu examples, like the "shadow" example.
Description
It seems like the framebuffers
hash map in the wgpu_hal::vulkan::CommandEncoder
is never reduced in size. This is problematic since hal command encoders are pooled and reused. The surface is updated each frame, so the FramebufferKey
never matches any of the old framebuffers. A new one is created each frame and the memory consumption grows unbounded.
Repro steps
Clone the wgpu trunk, run the shadow example on Vulkan and set the present mode to Immediate
(inside resume
in framework.rs
). Observe the used memory or add dbg!(self.framebuffers.len());
to the begin_render_pass
function in wgpu-hal/src/vulkan/command.rs
and see how the hash map length increases.
Expected vs observed behavior
I expected the pooled framebuffers to be destroyed after some time, or maybe when a length limitation is reached.
Extra materials
This console output should be sufficient [wgpu-hal/src/vulkan/command.rs:772:2] self.framebuffers.len() = 109383
:D
Platform
wgpu trunk, Ubuntu 22.04.02, Nvidia 570.153.02
Please excuse me if I missed something, this is my first issue and my knowledge of the wgpu code base is limited.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status