While trying to optimize a Unity game I discovered that font textures take up a ridiculous amount of memory on mobile devices (tested on Android - OnePlus 6). The texture does not seem to be cleared between scene switches, unlike the Editor, where the maximum size of a font texture is 4 MB at all times (even in the same scene with loads of different text elements) and does not climb any higher. Meanwhile, opening new scenes/windows with different texts increases the font texture memory even more and more on my phone. The attached image shows the profiler snippet when profiling my OnePlus 6 phone, after navigating to multiple scenes and opening different panels with various texts (which were using the same font).
My question is: what can I do about it - is it a bug or a feature? Why is the allocated texture memory not cleared/reset as it is on the Editor?I use the unity 2019.4.9f1 with dynamic font.
I made some recent improvements to the FontEngine used by TMP which should reduce the memory overhead of dynamic font assets.
If possible could you please submit a bug report with the project and information about your observations? This will enable me to further test these improvements but more importantly to post the expected results / improvements using the project you provided.
I have the same problem in unity 2019.4.x, and i use the ugui’s text component, font texture is 250MB on android, but i have no idea to solve it , could u tell how to solve this problem ?