Title: [165866] trunk/Source/WebCore
- Revision
- 165866
- Author
- [email protected]
- Date
- 2014-03-18 19:33:27 -0700 (Tue, 18 Mar 2014)
Log Message
Share MemoryPressureHandler::releaseMemory() between platforms.
<https://webkit.org/b/130416>
Move the code that scours WebKit for things we can free up right now
to the common part of MemoryPressureHandler. This will enable other
platforms to do the same thing under pressure.
There's now also a platformReleaseMemory() where platform-specific
pressure relief stuff can go.
Reviewed by Antti Koivisto.
* platform/MemoryPressureHandler.cpp:
(WebCore::MemoryPressureHandler::releaseMemory):
(WebCore::MemoryPressureHandler::platformReleaseMemory):
* platform/MemoryPressureHandler.h:
* platform/mac/MemoryPressureHandlerMac.mm:
(WebCore::MemoryPressureHandler::respondToMemoryPressure):
(WebCore::MemoryPressureHandler::platformReleaseMemory):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (165865 => 165866)
--- trunk/Source/WebCore/ChangeLog 2014-03-19 02:02:00 UTC (rev 165865)
+++ trunk/Source/WebCore/ChangeLog 2014-03-19 02:33:27 UTC (rev 165866)
@@ -1,3 +1,25 @@
+2014-03-18 Andreas Kling <[email protected]>
+
+ Share MemoryPressureHandler::releaseMemory() between platforms.
+ <https://webkit.org/b/130416>
+
+ Move the code that scours WebKit for things we can free up right now
+ to the common part of MemoryPressureHandler. This will enable other
+ platforms to do the same thing under pressure.
+
+ There's now also a platformReleaseMemory() where platform-specific
+ pressure relief stuff can go.
+
+ Reviewed by Antti Koivisto.
+
+ * platform/MemoryPressureHandler.cpp:
+ (WebCore::MemoryPressureHandler::releaseMemory):
+ (WebCore::MemoryPressureHandler::platformReleaseMemory):
+ * platform/MemoryPressureHandler.h:
+ * platform/mac/MemoryPressureHandlerMac.mm:
+ (WebCore::MemoryPressureHandler::respondToMemoryPressure):
+ (WebCore::MemoryPressureHandler::platformReleaseMemory):
+
2014-03-18 Dean Jackson <[email protected]>
[WebGL] Destroy EAGLContext's backing store
Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (165865 => 165866)
--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp 2014-03-19 02:02:00 UTC (rev 165865)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp 2014-03-19 02:33:27 UTC (rev 165866)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2011, 2014 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,6 +26,20 @@
#include "config.h"
#include "MemoryPressureHandler.h"
+#include "CSSValuePool.h"
+#include "Document.h"
+#include "Font.h"
+#include "FontCache.h"
+#include "GCController.h"
+#include "MemoryCache.h"
+#include "Page.h"
+#include "PageCache.h"
+#include "ScrollingThread.h"
+#include "StorageThread.h"
+#include "WorkerThread.h"
+#include <wtf/CurrentTime.h>
+#include <wtf/FastMalloc.h>
+#include <wtf/Functional.h>
#include <wtf/StdLibExtras.h>
namespace WebCore {
@@ -51,15 +65,43 @@
{
}
+void MemoryPressureHandler::releaseMemory(bool critical)
+{
+ int savedPageCacheCapacity = pageCache()->capacity();
+ pageCache()->setCapacity(0);
+ pageCache()->setCapacity(savedPageCacheCapacity);
+
+ fontCache()->purgeInactiveFontData();
+
+ memoryCache()->pruneToPercentage(0);
+
+ cssValuePool().drain();
+
+ clearWidthCaches();
+
+ for (auto* document : Document::allDocuments())
+ document->clearStyleResolver();
+
+ gcController().discardAllCompiledCode();
+
+ platformReleaseMemory(critical);
+
+ // FastMalloc has lock-free thread specific caches that can only be cleared from the thread itself.
+ StorageThread::releaseFastMallocFreeMemoryInAllThreads();
+ WorkerThread::releaseFastMallocFreeMemoryInAllThreads();
+#if ENABLE(ASYNC_SCROLLING)
+ ScrollingThread::dispatch(bind(WTF::releaseFastMallocFreeMemory));
+#endif
+ WTF::releaseFastMallocFreeMemory();
+}
+
#if !PLATFORM(MAC)
void MemoryPressureHandler::install() { }
void MemoryPressureHandler::uninstall() { }
void MemoryPressureHandler::holdOff(unsigned) { }
void MemoryPressureHandler::respondToMemoryPressure() { }
-#if !PLATFORM(IOS)
-void MemoryPressureHandler::releaseMemory(bool) { }
-#endif // !PLATFORM(IOS)
+void MemoryPressureHandler::platformReleaseMemory(bool) { }
#endif
Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.h (165865 => 165866)
--- trunk/Source/WebCore/platform/MemoryPressureHandler.h 2014-03-19 02:02:00 UTC (rev 165865)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.h 2014-03-19 02:33:27 UTC (rev 165866)
@@ -78,6 +78,7 @@
void respondToMemoryPressure();
static void releaseMemory(bool critical);
+ static void platformReleaseMemory(bool critical);
bool m_installed;
time_t m_lastRespondTime;
Modified: trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm (165865 => 165866)
--- trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm 2014-03-19 02:02:00 UTC (rev 165865)
+++ trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm 2014-03-19 02:33:27 UTC (rev 165866)
@@ -26,20 +26,8 @@
#import "config.h"
#import "MemoryPressureHandler.h"
-#import <WebCore/CSSValuePool.h>
-#import <WebCore/Document.h>
-#import <WebCore/GCController.h>
-#import <WebCore/FontCache.h>
-#import <WebCore/MemoryCache.h>
-#import <WebCore/Page.h>
-#import <WebCore/PageCache.h>
#import <WebCore/LayerPool.h>
-#import <WebCore/ScrollingThread.h>
-#import <WebCore/StorageThread.h>
-#import <WebCore/WorkerThread.h>
#import <wtf/CurrentTime.h>
-#import <wtf/FastMalloc.h>
-#import <wtf/Functional.h>
#import <malloc/malloc.h>
#if !PLATFORM(IOS)
@@ -146,38 +134,12 @@
holdOff(std::max(holdOffTime, s_minimumHoldOffTime));
}
-#endif // !PLATFORM(IOS)
-void MemoryPressureHandler::releaseMemory(bool)
+void MemoryPressureHandler::platformReleaseMemory(bool)
{
- int savedPageCacheCapacity = pageCache()->capacity();
- pageCache()->setCapacity(0);
- pageCache()->setCapacity(savedPageCacheCapacity);
-
- fontCache()->purgeInactiveFontData();
-
- memoryCache()->pruneToPercentage(0);
-
-#if !PLATFORM(IOS)
LayerPool::sharedPool()->drain();
-#endif
-
- cssValuePool().drain();
-
- clearWidthCaches();
-
- for (auto* document : Document::allDocuments())
- document->clearStyleResolver();
-
- gcController().discardAllCompiledCode();
-
- // FastMalloc has lock-free thread specific caches that can only be cleared from the thread itself.
- StorageThread::releaseFastMallocFreeMemoryInAllThreads();
- WorkerThread::releaseFastMallocFreeMemoryInAllThreads();
-#if ENABLE(ASYNC_SCROLLING)
- ScrollingThread::dispatch(bind(WTF::releaseFastMallocFreeMemory));
-#endif
- WTF::releaseFastMallocFreeMemory();
}
+#endif // !PLATFORM(IOS)
+
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes