wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

DX12: Memory leaks with intel gpu & 30+ driver

Open xiaopengli89 opened this issue 1 year ago • 5 comments

Description DX12 backend has memory leaks on some Intel drivers.

Repro steps

  1. Intel integrated gpu
  2. Setup intel 30+ gpu driver, e.g. 31.0.101.2128
  3. Running water example with dx12 backend

Extra materials image

20240822-163346

Platform Windows 10, wgpu 22.0

xiaopengli89 avatar Aug 22 '24 08:08 xiaopengli89

Is this a new leak?

teoxoy avatar Aug 30 '24 09:08 teoxoy

Is this a new leak?

No, it can be reproduced on older versions of wgpu, but there is no leak on the 27.x.x.x driver, maybe it's a driver bug.

xiaopengli89 avatar Aug 30 '24 09:08 xiaopengli89

I understand that the water example is a reproducer, so that's in principle all we need to look into this. But if you're able to, it would be nice to get a smaller test case, since water is one of the most complex of the examples.

jimblandy avatar Sep 09 '24 16:09 jimblandy

I have the same problem, but I'm using wgpu-native.
Specs:

RTX 3090 TI
WGPU version: 22.1.0.5
Backend: Vulkan, DX12 (doesn't depend on particular backend)

It looks like wgpu-core\src\device\queue.rs::PendingWrites::temp_resources was not released somewhere. I don't know rust and can't tell the reason.

Allocation stack trace: image

VadikPtr avatar Oct 02 '24 13:10 VadikPtr

I made reproduction example in rust https://github.com/cprkv/wgpu_mem_leak (in wgpu-native I do same things, so it has no difference, situation reproduces).

My guess is that uniform buffer is being used by GPU when I write to it. I took this approach from wgpu examples, and there is no comment if it does something wrong. I don't know if there is a correct example of how to do queue_write_buffer right.

I have to add this after some experiments:
It happens to both backends (Vulkan and DX12) in wgpu-native, but for some reason everything is fine for DX12 in wgpu (rust). Only Vulkan backend has noticeable leakage. I also tried using triple buffering technique (create 3 buffers and use it in round-robin manner), it doesn't help.

VadikPtr avatar Oct 03 '24 08:10 VadikPtr

P.S.: when I updated to version 23.0.1 problem is gone (https://github.com/cprkv/wgpu_mem_leak/tree/problem-solved).

VadikPtr avatar Jan 19 '25 07:01 VadikPtr

Going to close this then. If the issue re-occurs please file a new issue!

cwfitzgerald avatar Jan 19 '25 17:01 cwfitzgerald