On Oct 10, 2008, at 6:29 AM, Frederic Marmond wrote:

Hi people,
I just wonder how to clear the font cache, arbitrary.
For example, when leaving a site, clear all cached font data, to start loading the new page in a 'clean' environment.
I know it may slow down things :)  old memory vs speed debate...
I tried to call the FontCache::invalidate(); in my WebFrameLoaderClient::postProgressFinishedNotification(), but it doesn't do anything in my testcase.
I use valgrind to see what goes on.
my testcase is very simple:
first.html:
<span style="font-family: arial;">1234512345</span>
<a href="second.html">2</a>
second.html:
<span style="font-family: verdana;">a</span>
If I load first.html and then the second.html by clicking the link, then exit, I would expect memory be less used than if I only load first.html and exit. That's not the case, arial font datas are not cleared despite my invalidate() call. I'm a bit lost in the Font Cache, is there any guru that may kindly point me where to look? I tried to modify cTargetInactiveFontData and related parameters, without success, I can't manage to limit the font cache size... it grows and grows :(
Thanks in advance,
best regards
Fred

Hi Fred,

The way to clear the WebCore font cache is to invoke FontCache::purgeInactiveFontData(). This will remove all unreferenced font data from the cache. There is an amount of font data that is never released from the cache and therefore leaks, namely font data created in FontCache::getFontDataForCharacters. The call to invalidate() should release all other font data, but also re-create and re-cache font data for all active fonts. Perhaps by the time you call invalidate(), the render tree for the page has not been destroyed yet, so the fonts are referenced. I don’t know what valgrind measures, but in your simple test case you should be able to use the debugger to track all font data allocations and deallocations and specifically see whether and why purgeInactiveFontData() does not deallocate anything.

-- Dan
_______________________________________________
webkit-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to