-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory Leak in Compute Benchmark #674
Comments
So I have narrowed this down to the code which maps the buffer for readback of the result. Checkout the branch The code is a bit hard to navigate because of my buffer abstraction, so a few key points:
My initial hunch is that for some reason the buffer isn't getting unmapped properly, so it can't be freed. I am by no means skilled at reading wgpu logs, but the trace logs seem to indicate something similar to what I suspected. I have tried to reproduce it with just buffer copies, but was unsuccessful, meaning this is probably the smallest reproducible unit. |
In trying to get more information about another issue, I have found that this memory leak still exists on nvidia/windows. The TrackerSets just keep growing and growing seemly without bound when the work I'm doing should have it be very finite. I do wonder if my issue on nvidia is actually the same bug as this one, just manifesting differently. I will file an issue about that for record keeping's sake in case it's different and to give more information. |
I have been able to reproduce this bug on all platforms that I've tried, so hopefully reproducing it locally should be easy:
* stalls due to #677, but growing tracker sets can be observed in debug logs. |
I'm experiencing this leak on macOS as well |
Out of date |
Description
I am writing a couple compute benchmarks with wgpu and I am leaking memory quickly enough that it aborts with out of memory within 4-5 seconds of running.
This only happens when the device and queue are persisted over the lifespan of the benchmark. When they are re-created every loop, there is no memory leak. This is obviously a heavy-handed way to stop a leak, and causes issues on nvidia, which obviously doesn't like making a new adapter/device 10k times a second.
I have only been able to reproduce this on intel/linux, but that may be because nvidia/windows has other issues that prevent me from getting this far.
Repro steps
Repo: https://github.com/cwfitzgerald/wgpu-heterogeneous-compute-benchmark/
Working commit: 60be3275984f16b50eb6f45f9c618d6e33e10e07
Leaking commit: 09ce658cd8e968d44efd511ff575ff6344d56b1b
cargo bench -- 'addition/gpu staging/100000'
Should work out of the box. This should crash within 5-10 seconds, depending on exact circumstances.
Expected vs observed behavior
Expected: no leaks
Observed: leaks 😄
Extra materials
Logging from wgpu and backtrace:
Info logging (7mb): https://send.firefox.com/download/9e4a921bd2dc7849/#mC2AyYMgPXxYcCutPl3dnA
Trace logging (700mb!): https://send.firefox.com/download/f9d087c4b8a5d796/#3HJq8OJBws9pn6ftEAjdHA
I feel like debug/trace logging might give some interesting information.
Platform
wgpu-rs
master branchI've only tested the vulkan backend.
The text was updated successfully, but these errors were encountered: