WPF TextBlock memory leak when using Font

后端 未结 1 1956
没有蜡笔的小新
没有蜡笔的小新 2020-11-29 06:02

I\'m using .NET 4.5 on Windows 7, and might find a memory leak.
I have a TextBlock (not TextBox - it\'s not the Undo problem), which changes it

相关标签:
1条回答
  • 2020-11-29 06:40

    A FontFamily leaks UnmanagedMemoryStreams when it is used if it was sourced from an embedded resource or a relative path. When the FontFamily is sourced from a system font or absolute path, it does not leak.

    You can look here and download the project that reproduces the problem.

    Workaround: For Resource fonts: save fonts into a temporary folder and use the absolute path to the stored font. For relative path fonts: resolve and use the absolute path instead.

    0 讨论(0)
提交回复
热议问题