<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):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165866
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-03-18 Andreas Kling <akling@apple.com>
+
+ 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 <dino@apple.com>
[WebGL] Destroy EAGLContext's backing store
/*
- * 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
#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 {
{
}
+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
void respondToMemoryPressure();
static void releaseMemory(bool critical);
+ static void platformReleaseMemory(bool critical);
bool m_installed;
time_t m_lastRespondTime;
#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)
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