WPF TextBlock memory leak when using Font

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.

Leave a Comment