Is it expected for an EMPTY wgpu app to use 50MB?

I am no graphics expert (really just bystander), please excuse this potentially silly question :grinning_face_with_smiling_eyes:

I wanted to write a lightweight UI app using 'Iced' crate. Running simple example app I found that the memory footprint was around 60mb. For today's standards it's not much at all, but suppose you add some features and that memory footprint could potentially reach 100mb really fast (which is like typical electron app?:sweat_smile:)

As my initial dream was to build 5-15mb simple UI in Rust (for learning purposes), this got me very curious about what adds that overhead. After some digging I found that Iced uses gfx-rs/wgpu to render things. I compiled a "simple" cube example (from the wgpu repo) and it was using 50mb.

So, here's my question: Why wgpu uses this much RAM?
Is this an expected overhead for gpu-app? Is this some kind of driver overhead? Is it to store rendered frames? Maybe it's because of abstractions? Could it be improved?

I couldn't find any info about this anywhere else and I legitimately couldn't sleep because of it, so I am asking here :sweat_smile:

Note: I checked the memory usage on both Windows and Mac, running in develop and release modes, but the results were the same. Also similar results for empty window Bevy app.

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 insight. Thanks to it I was able to find more topics related.

Edit: In the end, it seems that most of the memory overhead comes from the underlying gpu-api.
(on mac) I ran cube example app from Vulkan-SDK and it uses around 50MB of memory just like the wgpu version of that app. This theoretically means that wgpu memory usage is justified given the API it is running on.

So answering my own question: initial overhead of simple wgpu app is expected and similar to the overhead of the back-end it is using (eg. Vulkan, Metal, DirectX).

So yeah, that was really weird question to ask.

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.