Gfx_hal updating from 0.6 to 0.7

Hey all!

I just updated my very basic code to render a triangle mesh from gfx_hal 0.6 to 0.7. I fixed all the compilation problems, like using iterators, some more &mut references and the framebuffer now requiring slightly different setup. Then I ran the program. It works, but I now get memory leaks, which I do not get using the 0.6 version.
I tried using only one framebuffer and destroying it at the end of the program as well as creating and destroying the framebuffer every loop (which was the way I think you did it in 0.6?).

Is there a resource which needs to be cleaned up now, but didn't in 0.6, or what could be the reason?

Do you have a repository somewhere where we can look at the code ?
Also don't know what tool you are using to detect this leak, but maybe valgrind could give you some insight about what caused it.

My code's too messy, don't wanna put all that work on you. I recreated the exact problem here
I just took the tutorial code from this tutorial and changed what you can see has changed in my commits (have two "tries" in to sperate commits).

You can run it with

cargo run --bin part-1-triangle

Edit: Forgot to answer your second part: I've just seen the memory usage creep up in my task manager by 4MB/s, but I always wanted to look into proper tools for this, so thank you for "valgrind".

Hmmm... I don't see anything suspicious in gfx_hal's changelog...

The only issue I had running the code was that it did not select the right adapter (and crashed with an obscure message later on, thanks vulkan :unamused:), but once it ran its memory usage was very stable: it has been 96±8 MB for about 20 minutes now, far from a 4MB/s leak.
Maybe this is platform specific (I ran the code on linux with the vulkan backend), in which case this might be a bug in one of the backends, or in winit ?

PS:
I perfectly understand the appeal of doing the truly low-level stuff, but if you haven't already I recommend you take a look at wgpu, a safe wrapper around gfx-hal maintained by the same people. It even has a pretty up-to-date tutorial ! :grin:
[end of ad]

I did not see anything on their changelog either, that's what confuses me the most.

I'm currently on windows, will try it on linux/with vulkan backend as well though, that's a good idea. If I can not reproduce the leak I'll file a bug on github.
(Yep the adapter selection in this example is really just take the first one, which worked for me but isn't a good general solution, sorry for not working on your end ._.)

I perfectly understand the appeal of doing the truly low-level stuff, but if you haven't already I recommend you take a look at wgpu , a safe wrapper around gfx-hal maintained by the same people. It even has a pretty up-to-date tutorial !

Thanks for the suggestion, but I'm actively teaching myself rust & low level graphics right now, so the struggle while annoying is welcome :smiley: I'll bookmark it though, might use it once I know how it works, seems a lot nicer to write safe code.

Ok, so using vulkan instead of dx 12 actually fixes the leak. Seems like I found a bug, how exciting :smiley:

I opened an issue on github.