Title: [179141] trunk/Source/WebCore
Revision
179141
Author
akl...@apple.com
Date
2015-01-26 13:42:40 -0800 (Mon, 26 Jan 2015)

Log Message

Don't let the CSSValuePool's font family cache grow unbounded.
<https://webkit.org/b/140894>

Reviewed by Chris Dumez.

Darin pointed out to Chris who pointed out to me that the font family cache
in CSSValuePool can grow unbounded until we get a system memory pressure
notification. Put a limit on it like we did with the font face cache.

* css/CSSValuePool.cpp:
(WebCore::CSSValuePool::createFontFamilyValue):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (179140 => 179141)


--- trunk/Source/WebCore/ChangeLog	2015-01-26 21:29:59 UTC (rev 179140)
+++ trunk/Source/WebCore/ChangeLog	2015-01-26 21:42:40 UTC (rev 179141)
@@ -1,5 +1,19 @@
 2015-01-26  Andreas Kling  <akl...@apple.com>
 
+        Don't let the CSSValuePool's font family cache grow unbounded.
+        <https://webkit.org/b/140894>
+
+        Reviewed by Chris Dumez.
+
+        Darin pointed out to Chris who pointed out to me that the font family cache
+        in CSSValuePool can grow unbounded until we get a system memory pressure
+        notification. Put a limit on it like we did with the font face cache.
+
+        * css/CSSValuePool.cpp:
+        (WebCore::CSSValuePool::createFontFamilyValue):
+
+2015-01-26  Andreas Kling  <akl...@apple.com>
+
         Plug leak in jsValueWithDictionaryInContext().
         <https://webkit.org/b/140889>
 

Modified: trunk/Source/WebCore/css/CSSValuePool.cpp (179140 => 179141)


--- trunk/Source/WebCore/css/CSSValuePool.cpp	2015-01-26 21:29:59 UTC (rev 179140)
+++ trunk/Source/WebCore/css/CSSValuePool.cpp	2015-01-26 21:42:40 UTC (rev 179141)
@@ -121,6 +121,11 @@
 
 Ref<CSSPrimitiveValue> CSSValuePool::createFontFamilyValue(const String& familyName, FromSystemFontIDOrNot fromSystemFontID)
 {
+    // Remove one entry at random if the cache grows too large.
+    const int maximumFontFamilyCacheSize = 128;
+    if (m_fontFamilyValueCache.size() >= maximumFontFamilyCacheSize)
+        m_fontFamilyValueCache.remove(m_fontFamilyValueCache.begin());
+
     RefPtr<CSSPrimitiveValue>& value = m_fontFamilyValueCache.add({familyName, fromSystemFontID}, nullptr).iterator->value;
     if (!value)
         value = CSSPrimitiveValue::create(CSSFontFamily{familyName, fromSystemFontID});
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to