-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Describe the bug
Hello
My program needs to display machine coordinates 30 times per second.
The form has a simple TextBlock:
The Feed field is of type double
Updating the field on the screen via:
OnPropertyChanged(nameof(Feed));
I encountered a memory leak (screenshots 1 and 2).


330 MB is leaked in 200 seconds.
Memory leaks occur even in idle apps, but very slowly and barely noticeably. You only notice it when elements are frequently updated.
I noticed that in the profiler, these strings are in objects somehow related to Font.
I started experimenting.
I came to the conclusion that the memory leak occurs every time the TextBlock is drawn via OnPropertyChanged(nameof(Feed)) – regardless of whether the data has changed or not.
And then I noticed that these TextBlocks had a style with an external font:
<Style Selector="Canvas.Big > TextBlock"> </Style>Where WhiteRabbit is an external font declared in App.axaml like this:
avares://JupiterCNC/Assets/Fonts/White Rabbit#White Rabbit
I disabled this font in the style, and the memory leak did not stop - but it decreased 100 times!
I tried rolling back to Avalonia 11.3.8 and the memory leak stopped.
AvaloniaUI 11.3.9
Net.core 10.0
Windows
To Reproduce
-
Add an external font to App.axaml:
<FontFamily x:Key="WhiteRabbit">avares://JupiterCNC/Assets/Fonts/White Rabbit#White Rabbit</FontFamily> -
Add this font to the TextBlock:
<Style Selector="Canvas.Big > TextBlock">
<Setter Property="FontFamily" Value="{StaticResource WhiteRabbit}"/>
</Style>
- Frequently refresh the Text in the TextBlock while working.
Expected behavior
No response
Avalonia version
11.3.9
OS
Windows
Additional context
No response