-
Memory usage of Rust programs compiled with Slint seems unexpected:
ExampleA program running in the background for a while, then creating a window and eventually closing again. Expected Behavior
Current BehaviorRAM usage on my system (Arch Linux, Wayland) for all three program phases. (Phase - QT - Winit)
Note that memory is not freed after dropping the UI and that QT immediately increases the memory footprint by a lot. Why is this an Issue?My use case is a service that will run in the background and wait for a signal to occasionally show an interactive window. Consuming more than 100MB for a dormant program is not acceptable in that case. Discussions #5854 and #3376 may be related. Adding |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
There are several cause of memory usage. Like caches at different level. For example, for the fonts, the images. Or within the GPU driver for some textures. Some of which we have control over, some of which we don't. |
Beta Was this translation helpful? Give feedback.
-
It makes sense that different backends on different platforms have different behavior, which is only partially under your control. I also think the memory required when rendering UI is absolutely fair! The things that surprised me are that just having Slint imported will immediately increase the memory footprint (with QT), even if nothing is drawn or explicitly initialized and that memory is not freed after dropping all objects. Is there any way to control this behavior? |
Beta Was this translation helpful? Give feedback.
Thanks for the extra details!
The increased memory with the Qt backend is likely due to how Qt initializes resources, including a font cache, even if no UI is shown. This is built into Qt to make later UI actions faster, but we don't have control over it.
As for memory not freeing after dropping all Slint objects, that’s due to caching. There’s currently no easy way to fully "unload" them once initialized.
If keeping memory low when idle is crucial, I’d recommend trying the winit backend with the
software
renderer, as it uses less memory overall.