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 12:47:51 +0100 |
commit | 325005697155853891ce4f23e7349931e748d7e7 (patch) | |
tree | 35c830a53041079fcb009496bd9129778f54165c /vcl/unx/generic/glyphs/glyphcache.cxx | |
parent | aac19da146d19033964d7c6ed608cfc4786f88c5 (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>
(cherry picked from commit e6aac0b637d583d3cfb893276f813ff5aa1ade17)
Reviewed-on: https://gerrit.libreoffice.org/83148
Diffstat (limited to 'vcl/unx/generic/glyphs/glyphcache.cxx')
-rw-r--r-- | vcl/unx/generic/glyphs/glyphcache.cxx | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx index 34543b7731a0..9640ea70adcf 100644 --- a/vcl/unx/generic/glyphs/glyphcache.cxx +++ b/vcl/unx/generic/glyphs/glyphcache.cxx @@ -199,6 +199,21 @@ void GlyphCache::UncacheFont( FreetypeFont& rFreetypeFont ) } } +void GlyphCache::TryGarbageCollectFont(LogicalFontInstance *pFontInstance) +{ + if (maFontList.empty() || !pFontInstance) + return; + FreetypeFontInstance* pFFI = dynamic_cast<FreetypeFontInstance*>(pFontInstance); + if (!pFFI) + return; + FreetypeFont* pFreetypeFont = pFFI->GetFreetypeFont(); + if (pFreetypeFont && (pFreetypeFont->GetRefCount() <= 0)) + { + mpCurrentGCFont = pFreetypeFont; + GarbageCollect(); + } +} + void GlyphCache::GarbageCollect() { // when current GC font has been destroyed get another one @@ -236,7 +251,11 @@ void GlyphCache::GarbageCollect() if( pFreetypeFont == mpCurrentGCFont ) mpCurrentGCFont = nullptr; - maFontList.erase(pFreetypeFont->GetFontInstance()); +#ifndef NDEBUG + int nErased = +#endif + maFontList.erase(pFreetypeFont->GetFontInstance()); + assert(1 == nErased); } } |