-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak when switching the theme #3640
Comments
I can replicate this with fyne_demo. |
I also raised it here #3755 where I provided an example. Please refer to the pprof output of that example when the RES memory was 1304M |
Looking at this trace, it seems to be font related and maybe it is the same issue as #3499 , but with more actionable data. |
It looks like somehow our font cache is not getting cleared to GC when the new theme arrives... |
I cannot replicate this on other OS, just like the font issue that is suspected to relate... |
@andydotxyz this issue was originally raised for Windows as per the screenshots provided. I was able to replicate it on Linux with the example in #3755. Which OS are you referring to? |
The example in #3755 is actually putting a lot of pressure on the gc which would explain that you could reproduce it in that case. The other things that might have an impact here is how much can your cpu process during a gc cycle. I would suspect that higher end system are less likely to see this problem. I think the problem is not so much a memory leak as it is a memory storm allocation that the gc on some system has trouble cleaning up fast enough. |
The #3755 has no increase in memory in v2.2.4. It stays ~45MiB at all times. So there is certainly a regression here. I understand that the new font functionality should increase the average memory in general, but it does not justify this gradual (indefinite) increase in memory in the new version v2.3.x |
Sorry, I am not saying that there is no problem just that the problem is not a leak in the sense of some piece of code keeping a reference to some data when it shouldn't, but that the code is allocating and discarding data too fast making it impossible for the gc on some system to keep up. |
Given that the GC is invoked every 2 minutes anyway, shouldn't I see a decrease in memory after a bit? I tested this with my main application. I manually invoked the theme change ~ 5-10 times and left it there. The memory stayed the same and never went down even if I left my application idle for more than 1hour. |
It would seem that somehow a reference to the font files is keeping them in memory after the cache clears! |
Aha! I have tracked it down to a font leak that I can replicate in the shaper without any Fyne code. |
In my testing it is resolved by go-text/typesetting#48. |
Actually that is exactly what it was - we shouldn't jump to conclusions. The fix upstream to go-text should resolve this completely. |
Resolved on develop, will back-port a similar fix to release branch |
i'm sorry to question once time, this in newest fyne it appear again, i use multiline entry, and use settext to update text, the memory add more |
This ticket is about switching theme. When you draw more items the memory will increase slightly. It will either be re-used or freed after a delay. |
Checklist
Describe the bug
Here is my demo project repository => passwdgen. When I try to switch the theme, the memory usage will increase 100~200 MB each time.
How to reproduce
Screenshots
Init
Switch to Light
Switch to Dark
Switch to Light again
Example code
Custom theme:
Switch theme:
Fyne version
2.3.0
Go compiler version
1.19.3
Operating system
Windows
Operating system version
Windows 10
Additional Information
No response
The text was updated successfully, but these errors were encountered: