WebGPU.NET icon indicating copy to clipboard operation
WebGPU.NET copied to clipboard

Memory Leak in HelloTriangle example

Open macromaniac opened this issue 1 year ago • 1 comments

Hi, great project.

In your HelloTriangle.csproj example there is a memory leak caused by not releasing the render pass encoder, view the diagnostic tools window in visual studio and observe the memory go up over time.

Recommend adding on line 383 of HelloTriangle.cs wgpuRenderPassEncoderRelease(renderPass);

macromaniac avatar Sep 04 '24 14:09 macromaniac

Also I think wgpuCommandBufferRelease(command); on line 393 too, there is still a light memory leak (.8 MB a minute), no clue where its coming from- it could be in the underlying lib, but it is 10x better with these two lines added

edit: seems like the .8 MB a minute is very likely a known wgpu bug that should be fixed in the next version, I found a workaround by releasing the underlying surface texture every frame but it is a bit ghetto so probably we shouldn't worry about it

macromaniac avatar Sep 04 '24 15:09 macromaniac