diff options
author | Jan-Marek Glogowski <jan-marek.glogowski@extern.cib.de> | 2019-11-16 02:21:26 +0000 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-11-19 03:13:06 +0100 |
commit | e6aac0b637d583d3cfb893276f813ff5aa1ade17 (patch) | |
tree | 431e2cc0115fb9fe7c36a978d189b66d23fb3b48 /vcl/inc/unx | |
parent | 578f97b4b2d06d3d5d5db7fd70066ba8ca665abc (diff) |
tdf#128434 try garbage collect ImplFontCache fonts
Instead of changing the harfbuzz caching, for this use case it's
enough to queue all per-OutputDevice fonts for garbage collection
(GC), which are managed by the OutputDevices ImplFontCache. So
just try to GC all the fonts in the ImplFontCache destructor.
There is no point keeping these LogicalFontInstances alive, after
the OutputDevice font cache is destroyed, as these fonts aren't
shared and can't be accessed later. But the main problem is still
some correct accounting of harfbuzz resources and eventual even
the Freetype ones, so this cleanup would not really be needed.
AFAI can tell, this plugs the remaining per-document leaks of the
PDF generation, except for a 72 byte basic listener leak from:
basic::ImplRepository::impl_createManagerForModel(...)
basicmanagerrepository.cxx:480
Change-Id: I3155be59a2bdcd85e01f6f048b990db04d88c94f
Reviewed-on: https://gerrit.libreoffice.org/82968
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/inc/unx')
-rw-r--r-- | vcl/inc/unx/glyphcache.hxx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx index 797890a2a345..f369952faac4 100644 --- a/vcl/inc/unx/glyphcache.hxx +++ b/vcl/inc/unx/glyphcache.hxx @@ -90,6 +90,19 @@ public: FreetypeFont* CacheFont(LogicalFontInstance* pFontInstance); void UncacheFont( FreetypeFont& ); + + /** Try to GarbageCollect an explicit logical font + * + * This should just be called from the ~ImplFontCache destructor, which holds the mapping of the + * FontSelectPattern to the LogicalFontInstance per OutputDevice. All other users should just + * call CacheFont and UncacheFont correctly. When the ImplFontCache is destroyed with its + * OutputDevice, we can safely garbage collection its unused entries, as these can't be reused. + * + * It's always safe to call this, as it just ignores the used bytes when considering a font for + * garbage collection, which normally keeps unreferenced fonts alive. + **/ + void TryGarbageCollectFont(LogicalFontInstance*); + void ClearFontCache(); void ClearFontOptions(); |