slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.94k stars 568 forks source link

Memory increases greatly when using default-font-family #3808

Closed zhoujun681 closed 7 months ago

zhoujun681 commented 10 months ago

Memory increases a lot when use default-font-family

Memory usage increases greatly when using Chinese fonts, even if the system has this font. Increased by 100m in win7 -_-. Can I load a certain character into memory only when I need to use it, instead of loading the entire font library into memory at once? export component HelloWorld inherits Window{ default-font-family: "微软雅黑"; ... }

tronical commented 10 months ago

Thank you for the report. It's understandable that a Chinese font has more characters and is larger on disk. But using it should not increase the amount of heap memory used. Fonts should be mapped from disk and not contribute to the heap.

How do you measure the memory sage?

Would it be possible for you to use VMMap and see how the different memory mappings change for your app when enabling and disabling the use of Chinese fonts?

tronical commented 10 months ago

For example, the widgets gallery for me maps two .ttf file into memory. Those don't contribute to the heap though, they merely occupy address space.

Screenshot 2023-11-03 at 10 14 51
tronical commented 7 months ago

Closing this as it's not clear what's actionable for us to do here, and I couldn't reproduce this issue either. Please re-open if you have more information that helps us reproduce this.