Is an empty wgpu app expected to use 50mb?

Please excuse this potentially silly question :smile:

I wanted to write a simple UI app using 'Iced' crate. Running one of the example apps I found that the memory footprint was around 60mb. It's not much for today's standards but my initial goal was to build a simple app under 5-15mb.

This got me curious about what is the reason behind that overhead. After some digging I found that Iced uses gfx-rs/wgpu to render things. I compiled a supposedly basic cube example (from the wgpu repo) and it was already using 50mb.

So, here's my question: Why wgpu uses this much RAM? Is this an expected overhead for any gpu app? Is this some kind of driver overhead? Could it be improved?

Note: I checked memory usage on both windows and mac, running in develop and release modes, but results were the same. I also got similar results running Bevy app with an empty window.

I am on Linux with Vulkan support. For me running the cube example gives an RSS of 50-80MB (changes while resizing, goes back to 80MB once I stop resizing) and shared memory of 55MB. Massif reported a peak memory usage of 44MB before it crashed with "parent device is lost". According to massif combined 16MB is allocated by the BuddyAllocator and FreeListAllocator in Device::map_memory. At least 18MB was used by the backtrace printing code. I think at the last point before the panic 24MB was used. Note that this 24MB figure is excluding memory reserved by the allocator. The memory allocator normally reserves ssome memory to allow it to quickly fulfill allocation requests without having to ask the kernel for new memory. I believe it frees part of it in case of memory pressure.

1 Like

Thank you for that. I got to find more resources related to this question.

It seems that most of the memory overhead comes from the underlying backend of wgpu. I ran cube example app from vulkan-sdk and it used around 50mb of memory just like the wgpu version of that app. So it makes sense that wgpu memory usage is the same as that of the backend it is running on.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.