toptensoftware/RichTextKit

Memory leak?

Jonesie opened this issue · 2 comments

Trying to track down a memory leak we noticed this:

Screenshot from 2021-06-08 12-49-32

We are really only using RichTextKit to measure and paint a text box. I have a custom FontMapper. Perhaps the typefaces are not getting disposed?

Can you post an example to repro this. There’s a bunch of use cases that might affect this (text block vs rich string etc) so need to know how you’re using it.

I think I resolved this.

Im using SkiaSharp and RichTextKit in an api to produce PDF, XPS and PNG files.

My custom FontMapper was being created many times so I added some request level caching based on a hash of the style so instead of having to create about 850 type faces, it now only creates 8 and they are correctly disposed when the request ends.

Im not sure if the default font mapper handles this, or how it could without knowing more about the use case but it might be useful to have a note in the documentation ... uneless there is already and I missed it.