Bug 17097

Summary: CGFontRefs (and HFONTs on Windows) leak because FontCache grows without bound
Product: WebKit Reporter: Adam Roben (:aroben) <aroben>
Component: TextAssignee: mitz
Status: RESOLVED FIXED    
Severity: Normal CC: eric, hyatt, mitz
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   

Description Adam Roben (:aroben) 2008-01-30 11:38:02 PST
The FontCache currently grows without bound, which means we're leaking the CGFontRefs and HFONTs used to construct the FontPlatformData objects held by the cache.
Comment 1 Adam Roben (:aroben) 2008-01-30 11:39:03 PST
Some quotes from Hyatt on this issue:

<dhyatt> it's not obvious how to change it without hurting perf
<dhyatt> the tentative idea i had was to refcount FontDatas
<dhyatt> and just pretend like FontPlatformData is always a "temporary"
<dhyatt> to avoid massive refcount churn on the fontplatformdata
<dhyatt> if you look at fontdata's destructor
<dhyatt> (i guess simplefontdata now)
<dhyatt> it does actually have code to delete the HFONT and release the cgfontref
<dhyatt> it never gets called
<dhyatt> i just mean i wrote the code assuming that someday the fontdatas would get destroyed
<dhyatt> purged from the cache etc
Comment 2 Adam Roben (:aroben) 2008-01-30 11:39:44 PST
<rdar://problem/5715471>
Comment 3 mitz 2008-04-01 19:25:00 PDT
*** Bug 18263 has been marked as a duplicate of this bug. ***
Comment 4 Eric Seidel (no email) 2008-04-01 22:35:52 PDT
This doesn't matter much on OS X (I don't think).  But on Windows, there are only 65k GDI Object Handles  per user session.  These handle "leaks" can end up causing Safari to take up an unfair number of handles.
Comment 5 mitz 2008-04-01 23:04:31 PDT
The HFONTs are now owned by the FontPlatformData (not the SimpleFontData). One possible solution would be to have a way to invalidate those and make the SimpleFontData check the validity before any other accees. You'll also need a way to regenerate the FontPlatformData if they were invalidated (you need a FontDescription and a family name for that IIRC).
Comment 6 mitz 2008-05-12 14:07:47 PDT
Fixed in <http://trac.webkit.org/changeset/33056>.
Comment 7 mitz 2008-05-31 00:57:39 PDT
The bug is not fixed in TOT. PlatformFontData objects which hold on to HFONTs and CGFontRefs are still held indefinitely by the FontPlatformDataCache.
Comment 8 mitz 2008-07-25 12:12:11 PDT
<http://trac.webkit.org/changeset/35352>.