Skip to content

Conversation

@mariovisic
Copy link
Contributor

Previously we would cache every font that the user created that had a unique
font face, size and any styles (such as bold or italic).

This meant that if you increased the font size by a tiny fraction every frame,
then it would create a new font object every frame, resulting in 1000s of fonts
that we cached and never let go. In these circumstances it's easier to not
attempt to cache all of the fonts, and so setting a limit of 100 fonts to cache
as the maximum means that we can limit the amount of memory the program will
consume, 100 font variations should be plenty for most programs and programs
that use more will pay a small performance penalty but they won't have
uncontrolled memory growth any more.

Previously we would cache every font that the user created that had a unique
font face, size and any styles (such as bold or italic).

This meant that if you increased the font size by a tiny fraction every frame,
then it would create a new font object every frame, resulting in 1000s of fonts
that we cached and never let go. In these circumstances it's easier to not
attempt to cache all of the fonts, and so setting a limit of 100 fonts to cache
as the maximum means that we can limit the amount of memory the program will
consume, 100 font variations should be plenty for most programs and programs
that use more will pay a small performance penalty but they won't have
uncontrolled memory growth any more.
@blacktm blacktm merged commit 2c2f4ef into main Dec 11, 2021
@blacktm blacktm deleted the limit_max_cached_fonts branch December 11, 2021 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants