bug 717175 - flush shaped-word caches if they grow excessively large. r=roc a=akeybl
authorJonathan Kew <jkew@mozilla.com>
Tue, 03 Apr 2012 12:22:18 +0100
changeset 92011 ac19f9e7096e7095ffb860f79a55e67137dca574
parent 92010 2fe257c037f1efe835db9090f7b800983d480a76
child 92012 a923cadf7b8d6bbefd7a9dd12003d7357c226f96
push idunknown
push userunknown
push dateunknown
reviewersroc, akeybl
bugs717175
milestone13.0a2
bug 717175 - flush shaped-word caches if they grow excessively large. r=roc a=akeybl
gfx/thebes/gfxFont.cpp
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -1918,16 +1918,22 @@ gfxShapedWord*
 gfxFont::GetShapedWord(gfxContext *aContext,
                        const T *aText,
                        PRUint32 aLength,
                        PRUint32 aHash,
                        PRInt32 aRunScript,
                        PRInt32 aAppUnitsPerDevUnit,
                        PRUint32 aFlags)
 {
+    // if the cache is getting too big, flush it and start over
+    if (mWordCache.Count() > 10000) {
+        NS_WARNING("flushing shaped-word cache");
+        ClearCachedWords();
+    }
+
     // if there's a cached entry for this word, just return it
     CacheHashKey key(aText, aLength, aHash,
                      aRunScript,
                      aAppUnitsPerDevUnit,
                      aFlags);
 
     CacheHashEntry *entry = mWordCache.PutEntry(key);
     gfxShapedWord *sw = entry->mShapedWord;