Title: [88261] trunk/Source/WebCore
Revision
88261
Author
msab...@apple.com
Date
2011-06-07 13:49:01 -0700 (Tue, 07 Jun 2011)

Log Message

2011-06-07  Michael Saboff  <msab...@apple.com>

        Reviewed by Geoffrey Garen.

        Need to enable font cache purging in MemoryPressureHandler
        https://bugs.webkit.org/show_bug.cgi?id=62060

        Improve memory usage under pressure.
        Added call to fontCache()->purgeInactiveFontData() in 
        MemoryPressureHandler::respondToMemoryPressure().  Added protection to 
        MemoryPressureHandler::install() being called multiple times.

        No new tests as funtionality wasn't changed.

        * platform/MemoryPressureHandler.cpp:
        (WebCore::MemoryPressureHandler::MemoryPressureHandler):
        * platform/MemoryPressureHandler.h:
        * platform/mac/MemoryPressureHandlerMac.mm:
        (WebCore::MemoryPressureHandler::install):
        (WebCore::MemoryPressureHandler::respondToMemoryPressure):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (88260 => 88261)


--- trunk/Source/WebCore/ChangeLog	2011-06-07 20:46:28 UTC (rev 88260)
+++ trunk/Source/WebCore/ChangeLog	2011-06-07 20:49:01 UTC (rev 88261)
@@ -2,6 +2,27 @@
 
         Reviewed by Geoffrey Garen.
 
+        Need to enable font cache purging in MemoryPressureHandler
+        https://bugs.webkit.org/show_bug.cgi?id=62060
+
+        Improve memory usage under pressure.
+        Added call to fontCache()->purgeInactiveFontData() in 
+        MemoryPressureHandler::respondToMemoryPressure().  Added protection to 
+        MemoryPressureHandler::install() being called multiple times.
+
+        No new tests as funtionality wasn't changed.
+
+        * platform/MemoryPressureHandler.cpp:
+        (WebCore::MemoryPressureHandler::MemoryPressureHandler):
+        * platform/MemoryPressureHandler.h:
+        * platform/mac/MemoryPressureHandlerMac.mm:
+        (WebCore::MemoryPressureHandler::install):
+        (WebCore::MemoryPressureHandler::respondToMemoryPressure):
+
+2011-06-07  Michael Saboff  <msab...@apple.com>
+
+        Reviewed by Geoffrey Garen.
+
         Fonts returned by FontCache::getFontDataForCharacters() are never released
         https://bugs.webkit.org/show_bug.cgi?id=61875
 

Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (88260 => 88261)


--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp	2011-06-07 20:46:28 UTC (rev 88260)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp	2011-06-07 20:49:01 UTC (rev 88261)
@@ -36,7 +36,10 @@
     return staticMemoryPressureHandler;
 }
 
-MemoryPressureHandler::MemoryPressureHandler() { }
+MemoryPressureHandler::MemoryPressureHandler() 
+    : m_installed(false)
+{
+}
 
 #if !PLATFORM(MAC) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
 void MemoryPressureHandler::install() { }

Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.h (88260 => 88261)


--- trunk/Source/WebCore/platform/MemoryPressureHandler.h	2011-06-07 20:46:28 UTC (rev 88260)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.h	2011-06-07 20:49:01 UTC (rev 88261)
@@ -41,6 +41,8 @@
     ~MemoryPressureHandler();
 
     void respondToMemoryPressure();
+
+    bool m_installed;
 };
  
 // Function to obtain the global memory pressure object.

Modified: trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm (88260 => 88261)


--- trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm	2011-06-07 20:46:28 UTC (rev 88260)
+++ trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm	2011-06-07 20:49:01 UTC (rev 88261)
@@ -27,6 +27,7 @@
 #import "MemoryPressureHandler.h"
 
 #import <WebCore/GCController.h>
+#import <WebCore/FontCache.h>
 #import <WebCore/MemoryCache.h>
 #import <WebCore/PageCache.h>
 #import <wtf/FastMalloc.h>
@@ -58,30 +59,31 @@
 
 void MemoryPressureHandler::install()
 {
-    if (!_cache_event_source) {
-        dispatch_async(dispatch_get_main_queue(), ^{
-            _cache_event_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VM, 0, DISPATCH_VM_PRESSURE, dispatch_get_main_queue());
-            if (_cache_event_source) {
-                dispatch_set_context(_cache_event_source, this);
-                dispatch_source_set_event_handler(_cache_event_source, ^{ memoryPressureHandler().respondToMemoryPressure();});
-                dispatch_resume(_cache_event_source);
-            }
-        });
-    }
+    if (m_installed)
+        return;
 
+    dispatch_async(dispatch_get_main_queue(), ^{
+        _cache_event_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VM, 0, DISPATCH_VM_PRESSURE, dispatch_get_main_queue());
+        if (_cache_event_source) {
+            dispatch_set_context(_cache_event_source, this);
+            dispatch_source_set_event_handler(_cache_event_source, ^{ memoryPressureHandler().respondToMemoryPressure();});
+            dispatch_resume(_cache_event_source);
+        }
+    });
+
 #ifndef NDEBUG
-    if (!_cache_event_source2) {
-        dispatch_async(dispatch_get_main_queue(), ^{
-            _cache_event_source2 = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGUSR2, 0, dispatch_get_main_queue());
-            if (_cache_event_source2) {
-                dispatch_set_context(_cache_event_source2, this);
-                dispatch_source_set_event_handler(_cache_event_source2, ^{ memoryPressureHandler().respondToMemoryPressure();});
-                dispatch_resume(_cache_event_source2);
-                signal((int)SIGUSR2, SIG_IGN);
-            }
-        });
-    }
+    dispatch_async(dispatch_get_main_queue(), ^{
+        _cache_event_source2 = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGUSR2, 0, dispatch_get_main_queue());
+        if (_cache_event_source2) {
+            dispatch_set_context(_cache_event_source2, this);
+            dispatch_source_set_event_handler(_cache_event_source2, ^{ memoryPressureHandler().respondToMemoryPressure();});
+            dispatch_resume(_cache_event_source2);
+            signal((int)SIGUSR2, SIG_IGN);
+        }
+    });
 #endif
+
+    m_installed = true;
 }
 
 void MemoryPressureHandler::respondToMemoryPressure()
@@ -96,6 +98,8 @@
     [nsurlCache setMemoryCapacity:[nsurlCache currentMemoryUsage]/2];
     [nsurlCache setMemoryCapacity:savedNsurlCacheMemoryCapacity];
  
+    fontCache()->purgeInactiveFontData();
+
     memoryCache()->pruneToPercentage(0.5f);
 
     gcController().garbageCollectNow();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to