I am changing font size with UISlider and pinch gesture.
lable.font = font.withSize(updatedFontSize)As every time font changes, app consumes few amount of memory(eg. ~0.01mb). As rendering/initialising font is little bit expensive, iOS tends to cache UIFont into OS which is the cause of this memory consumption(got explanation from this SO question). After changing font rapidly for few times, iOS starts to check if that font is available on cache. With slider/gesture, thousands font size can be produced and those will be stored into UIFontCache.
Changing font continuously for few minutes,
+[UIFont _fontWithDescriptor:size:textStyleForScaling:pointSizeForScaling:maximumPointSizeAfterScaling:forIB:]started to take huge amount of cpu.
This cause glitch on my UILabel while changing the font size. Is there any way to prevent this higher cpu usage to preventing this glitch?
Is there any way to prevent UILable to cache UIFont? or a way to clear the UICache of UIFont programatically.
Here is my Time profile Instrument's screenshot https://imgur.com/a/wnpzo5F