+2017-02-02 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r211571 and r211582.
+ https://bugs.webkit.org/show_bug.cgi?id=167751
+
+ This change caused API test WebKit1.MemoryPressureHandler to
+ fail with an assertion. (Requested by ryanhaddad on #webkit).
+
+ Reverted changesets:
+
+ "[Mac] In-process memory pressure monitor for WebContent
+ processes."
+ https://bugs.webkit.org/show_bug.cgi?id=167491
+ http://trac.webkit.org/changeset/211571
+
+ "Unreviewed attempt to fix the Windows build after r211571."
+ http://trac.webkit.org/changeset/211582
+
2017-02-02 Andreas Kling <akling@apple.com>
[Mac] In-process memory pressure monitor for WebContent processes.
m_sweeper->startSweeping();
}
+NEVER_INLINE void Heap::didExceedMaxLiveSize()
+{
+ CRASH();
+}
+
void Heap::updateAllocationLimits()
{
static const bool verbose = false;
if (verbose)
dataLog("extraMemorySize() = ", extraMemorySize(), ", currentHeapSize = ", currentHeapSize, "\n");
+
+ if (m_maxLiveSize && currentHeapSize > m_maxLiveSize)
+ didExceedMaxLiveSize();
if (Options::gcMaxHeapSize() && currentHeapSize > Options::gcMaxHeapSize())
HeapStatistics::exitWithFailure();
VM* vm() const;
+ // Set a hard limit where JSC will crash if live heap size exceeds it.
+ void setMaxLiveSize(size_t size) { m_maxLiveSize = size; }
+
MarkedSpace& objectSpace() { return m_objectSpace; }
MachineThreads& machineThreads() { return m_machineThreads; }
size_t m_blockBytesAllocated { 0 };
size_t m_externalMemorySize { 0 };
#endif
+
+ NO_RETURN_DUE_TO_CRASH void didExceedMaxLiveSize();
+ size_t m_maxLiveSize { 0 };
std::unique_ptr<MutatorScheduler> m_scheduler;
+2017-02-02 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r211571 and r211582.
+ https://bugs.webkit.org/show_bug.cgi?id=167751
+
+ This change caused API test WebKit1.MemoryPressureHandler to
+ fail with an assertion. (Requested by ryanhaddad on #webkit).
+
+ Reverted changesets:
+
+ "[Mac] In-process memory pressure monitor for WebContent
+ processes."
+ https://bugs.webkit.org/show_bug.cgi?id=167491
+ http://trac.webkit.org/changeset/211571
+
+ "Unreviewed attempt to fix the Windows build after r211571."
+ http://trac.webkit.org/changeset/211582
+
2017-02-02 Andreas Kling <akling@apple.com>
[Mac] In-process memory pressure monitor for WebContent processes.
A8A47487151A825B004123FF /* WTFThreadData.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4737B151A825B004123FF /* WTFThreadData.h */; };
A8A4748C151A8264004123FF /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4748B151A8264004123FF /* config.h */; };
AD7C434B1DD2A4A70026888B /* Expected.h in Headers */ = {isa = PBXBuildFile; fileRef = AD7C434A1DD2A4A70026888B /* Expected.h */; };
- ADF2CE661E39F106006889DB /* MemoryFootprint.h in Headers */ = {isa = PBXBuildFile; fileRef = ADF2CE641E39F106006889DB /* MemoryFootprint.h */; settings = {ATTRIBUTES = (Private, ); }; };
- ADF2CE671E39F106006889DB /* MemoryFootprint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADF2CE651E39F106006889DB /* MemoryFootprint.cpp */; };
B38FD7BD168953E80065C969 /* FeatureDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = B38FD7BC168953E80065C969 /* FeatureDefines.h */; };
C4F8A93719C65EB400B2B15D /* Stopwatch.h in Headers */ = {isa = PBXBuildFile; fileRef = C4F8A93619C65EB400B2B15D /* Stopwatch.h */; };
C8B0E1A1E01A486EB95E0D11 /* IndexSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 3137E1D7DBD84AC38FAE4D34 /* IndexSet.h */; };
A8A4737B151A825B004123FF /* WTFThreadData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTFThreadData.h; sourceTree = "<group>"; };
A8A4748B151A8264004123FF /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
AD7C434A1DD2A4A70026888B /* Expected.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Expected.h; sourceTree = "<group>"; };
- ADF2CE641E39F106006889DB /* MemoryFootprint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryFootprint.h; sourceTree = "<group>"; };
- ADF2CE651E39F106006889DB /* MemoryFootprint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryFootprint.cpp; sourceTree = "<group>"; };
B38FD7BC168953E80065C969 /* FeatureDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FeatureDefines.h; sourceTree = "<group>"; };
C4F8A93619C65EB400B2B15D /* Stopwatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Stopwatch.h; sourceTree = "<group>"; };
CD5497AA15857D0300B5BC30 /* MediaTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaTime.cpp; sourceTree = "<group>"; };
A8A472CB151A825B004123FF /* MD5.h */,
CD5497AA15857D0300B5BC30 /* MediaTime.cpp */,
CD5497AB15857D0300B5BC30 /* MediaTime.h */,
- ADF2CE641E39F106006889DB /* MemoryFootprint.h */,
- ADF2CE651E39F106006889DB /* MemoryFootprint.cpp */,
A8A472CC151A825B004123FF /* MessageQueue.h */,
A8A472CD151A825B004123FF /* MetaAllocator.cpp */,
A8A472CE151A825B004123FF /* MetaAllocator.h */,
A8A4741C151A825B004123FF /* RefPtr.h in Headers */,
A8A4741E151A825B004123FF /* RetainPtr.h in Headers */,
2CDED0F418115C85004DBA70 /* RunLoop.h in Headers */,
- ADF2CE661E39F106006889DB /* MemoryFootprint.h in Headers */,
1469419216EAAF6D0024E146 /* RunLoopTimer.h in Headers */,
A5098B001C169E0700087797 /* SandboxSPI.h in Headers */,
14F3B0F715E45E4600210069 /* SaturatedArithmetic.h in Headers */,
1ACADD841884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm in Sources */,
A8A473AE151A825B004123FF /* diy-fp.cc in Sources */,
A8A473B0151A825B004123FF /* double-conversion.cc in Sources */,
- ADF2CE671E39F106006889DB /* MemoryFootprint.cpp in Sources */,
A8A473BA151A825B004123FF /* dtoa.cpp in Sources */,
A8A473B3151A825B004123FF /* fast-dtoa.cc in Sources */,
0F7C5FB61D885CF20044F5E2 /* FastBitVector.cpp in Sources */,
MallocPtr.h
MathExtras.h
MediaTime.h
- MemoryFootprint.h
MessageQueue.h
MetaAllocator.h
MetaAllocatorHandle.h
MD5.cpp
MainThread.cpp
MediaTime.cpp
- MemoryFootprint.cpp
MetaAllocator.cpp
MonotonicTime.cpp
NumberOfCores.cpp
+++ /dev/null
-/*
- * Copyright (C) 2017 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "MemoryFootprint.h"
-
-#if PLATFORM(COCOA)
-#include <mach/mach.h>
-#include <mach/task_info.h>
-#endif
-
-namespace WTF {
-
-std::optional<size_t> memoryFootprint()
-{
-#if PLATFORM(COCOA)
- task_vm_info_data_t vmInfo;
- mach_msg_type_number_t count = TASK_VM_INFO_COUNT;
- kern_return_t result = task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &vmInfo, &count);
- if (result != KERN_SUCCESS)
- return std::nullopt;
- return static_cast<size_t>(vmInfo.phys_footprint);
-#else
- return std::nullopt;
-#endif
-}
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <wtf/Optional.h>
-
-namespace WTF {
-
-WTF_EXPORT_PRIVATE std::optional<size_t> memoryFootprint();
-
-}
-
-using WTF::memoryFootprint;
-
+2017-02-02 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r211571 and r211582.
+ https://bugs.webkit.org/show_bug.cgi?id=167751
+
+ This change caused API test WebKit1.MemoryPressureHandler to
+ fail with an assertion. (Requested by ryanhaddad on #webkit).
+
+ Reverted changesets:
+
+ "[Mac] In-process memory pressure monitor for WebContent
+ processes."
+ https://bugs.webkit.org/show_bug.cgi?id=167491
+ http://trac.webkit.org/changeset/211571
+
+ "Unreviewed attempt to fix the Windows build after r211571."
+ http://trac.webkit.org/changeset/211582
+
2017-02-02 Chris Dumez <cdumez@apple.com>
Unreviewed attempt to fix the Windows build after r211571.
ScriptController::initializeThreading();
g_commonVMOrNull = &VM::createLeaked(LargeHeap).leakRef();
+#if CPU(X86_64) || CPU(ARM64)
+ static const size_t maxGCHeapSize = 4 * GB;
+ g_commonVMOrNull->heap.setMaxLiveSize(maxGCHeapSize);
+#endif
g_commonVMOrNull->heap.acquireAccess(); // At any time, we may do things that affect the GC.
#if !PLATFORM(IOS)
g_commonVMOrNull->setExclusiveThread(std::this_thread::get_id());
if (m_documentLoader)
m_documentLoader->stopRecordingResponses();
if (m_frame.isMainFrame() && oldState != newState)
- static_cast<MainFrame&>(m_frame).didCompleteLoad();
+ static_cast<MainFrame&>(m_frame).performanceLogging().didReachPointOfInterest(PerformanceLogging::MainFrameLoadCompleted);
}
}
tree().removeChild(*child);
}
-void MainFrame::didCompleteLoad()
-{
- m_timeOfLastCompletedLoad = MonotonicTime::now();
- performanceLogging().didReachPointOfInterest(PerformanceLogging::MainFrameLoadCompleted);
-}
-
#if PLATFORM(MAC)
ScrollLatchingState* MainFrame::latchingState()
{
PerformanceLogging& performanceLogging() const { return *m_performanceLogging; }
- void didCompleteLoad();
- MonotonicTime timeOfLastCompletedLoad() const { return m_timeOfLastCompletedLoad; }
-
private:
MainFrame(Page&, PageConfiguration&);
#endif
std::unique_ptr<PerformanceLogging> m_performanceLogging;
-
- MonotonicTime m_timeOfLastCompletedLoad;
};
} // namespace WebCore
#include "CSSValuePool.h"
#include "Chrome.h"
#include "ChromeClient.h"
-#include "CommonVM.h"
#include "Document.h"
#include "FontCache.h"
#include "GCController.h"
#include "HTMLMediaElement.h"
#include "InlineStyleSheetOwner.h"
#include "InspectorInstrumentation.h"
-#include "Logging.h"
-#include "MainFrame.h"
#include "MemoryCache.h"
#include "Page.h"
#include "PageCache.h"
#include "WorkerThread.h"
#include <wtf/FastMalloc.h>
-#if PLATFORM(COCOA)
-#include "ResourceUsageThread.h"
-#endif
-
namespace WebCore {
static void releaseNoncriticalMemory()
#endif
}
-#if !RELEASE_LOG_DISABLED
-static unsigned pageCount()
-{
- unsigned count = 0;
- Page::forEachPage([&] (Page& page) {
- if (!page.isUtilityPage())
- ++count;
- });
- return count;
-}
-#endif
-
-void logMemoryStatisticsAtTimeOfDeath()
-{
-#if !RELEASE_LOG_DISABLED
-#if PLATFORM(COCOA)
- auto pageSize = vmPageSize();
- auto pages = pagesPerVMTag();
-
- RELEASE_LOG(MemoryPressure, "Dirty memory per VM tag at time of death:");
- for (unsigned i = 0; i < 256; ++i) {
- size_t dirty = pages[i].dirty * pageSize;
- if (!dirty)
- continue;
- String tagName = displayNameForVMTag(i);
- if (!tagName)
- tagName = String::format("Tag %u", i);
- RELEASE_LOG(MemoryPressure, "%16s: %lu MB", tagName.latin1().data(), dirty / MB);
- }
-#endif
-
- auto& vm = commonVM();
- RELEASE_LOG(MemoryPressure, "Memory usage statistics at time of death:");
- RELEASE_LOG(MemoryPressure, "GC heap size: %zu", vm.heap.size());
- RELEASE_LOG(MemoryPressure, "GC heap extra memory size: %zu", vm.heap.extraMemorySize());
-#if ENABLE(RESOURCE_USAGE)
- RELEASE_LOG(MemoryPressure, "GC heap external memory: %zu", vm.heap.externalMemorySize());
-#endif
- RELEASE_LOG(MemoryPressure, "Global object count: %zu", vm.heap.globalObjectCount());
-
- RELEASE_LOG(MemoryPressure, "Page count: %u", pageCount());
- RELEASE_LOG(MemoryPressure, "Document count: %u", Document::allDocuments().size());
- RELEASE_LOG(MemoryPressure, "Live JavaScript objects:");
- for (auto& it : *vm.heap.objectTypeCounts())
- RELEASE_LOG(MemoryPressure, " %s: %d", it.key, it.value);
-#endif
-}
-
-void didExceedMemoryLimitAndFailedToRecover()
-{
- RELEASE_LOG(MemoryPressure, "Crashing non-visible process due to excessive memory usage + inability to free up memory below panic threshold.");
- logMemoryStatisticsAtTimeOfDeath();
- CRASH();
-}
-
-bool processIsEligibleForMemoryKill()
-{
- bool hasVisiblePages = false;
- bool hasAudiblePages = false;
- bool hasMainFrameNavigatedInTheLastHour = false;
-
- auto now = MonotonicTime::now();
- Page::forEachPage([&] (Page& page) {
- if (page.isUtilityPage())
- return;
- if (page.isVisible())
- hasVisiblePages = true;
- if (page.activityState() & ActivityState::IsAudible)
- hasAudiblePages = true;
- if (auto timeOfLastCompletedLoad = page.mainFrame().timeOfLastCompletedLoad()) {
- if (now - timeOfLastCompletedLoad <= Seconds::fromMinutes(60))
- hasMainFrameNavigatedInTheLastHour = true;
- }
- });
-
- bool eligible = !hasVisiblePages && !hasAudiblePages && !hasMainFrameNavigatedInTheLastHour;
- if (!eligible)
- RELEASE_LOG(MemoryPressure, "Process not eligible for panic memory kill. Reasons: hasVisiblePages=%u, hasAudiblePages=%u, hasMainFrameNavigatedInTheLastHour=%u", hasVisiblePages, hasAudiblePages, hasMainFrameNavigatedInTheLastHour);
-
- return eligible;
-}
-
#if !PLATFORM(COCOA)
void platformReleaseMemory(Critical) { }
void jettisonExpensiveObjectsOnTopLevelNavigation() { }
void platformReleaseMemory(Critical);
void jettisonExpensiveObjectsOnTopLevelNavigation();
WEBCORE_EXPORT void registerMemoryReleaseNotifyCallbacks();
-WEBCORE_EXPORT void logMemoryStatisticsAtTimeOfDeath();
-WEBCORE_EXPORT NO_RETURN_DUE_TO_CRASH void didExceedMemoryLimitAndFailedToRecover();
-WEBCORE_EXPORT bool processIsEligibleForMemoryKill();
} // namespace WebCore
};
const char* displayNameForVMTag(unsigned);
-size_t vmPageSize();
std::array<TagInfo, 256> pagesPerVMTag();
void logFootprintComparison(const std::array<TagInfo, 256>&, const std::array<TagInfo, 256>&);
#endif
namespace WebCore {
-size_t vmPageSize()
+static size_t vmPageSize()
{
#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
return vm_kernel_page_size;
/*
- * Copyright (C) 2011-2017 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 "MemoryPressureHandler.h"
#include "Logging.h"
-#include <wtf/MemoryFootprint.h>
namespace WebCore {
}
MemoryPressureHandler::MemoryPressureHandler()
- : m_measurementTimer(RunLoop::main(), this, &MemoryPressureHandler::measurementTimerFired)
#if OS(LINUX)
- , m_holdOffTimer(RunLoop::main(), this, &MemoryPressureHandler::holdOffTimerFired)
+ : m_holdOffTimer(RunLoop::main(), this, &MemoryPressureHandler::holdOffTimerFired)
#endif
{
}
-void MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor(bool use)
-{
- if (use)
- m_measurementTimer.startRepeating(30);
- else
- m_measurementTimer.stop();
-}
-
-#if !RELEASE_LOG_DISABLED
-static const char* toString(MemoryUsagePolicy policy)
-{
- switch (policy) {
- case MemoryUsagePolicy::Unrestricted: return "Unrestricted";
- case MemoryUsagePolicy::Conservative: return "Conservative";
- case MemoryUsagePolicy::Strict: return "Strict";
- case MemoryUsagePolicy::Panic: return "Panic";
- }
-}
-#endif
-
-static inline size_t thresholdForPolicy(MemoryUsagePolicy policy)
-{
- switch (policy) {
- case MemoryUsagePolicy::Conservative:
- return 1 * GB;
- case MemoryUsagePolicy::Strict:
- return 2 * GB;
- case MemoryUsagePolicy::Panic:
-#if CPU(X86_64) || CPU(ARM64)
- return 4 * GB;
-#else
- return 3 * GB;
-#endif
- case MemoryUsagePolicy::Unrestricted:
- default:
- ASSERT_NOT_REACHED();
- return 0;
- }
-}
-
-static inline MemoryUsagePolicy policyForFootprint(size_t footprint)
-{
- if (footprint >= thresholdForPolicy(MemoryUsagePolicy::Panic))
- return MemoryUsagePolicy::Panic;
- if (footprint >= thresholdForPolicy(MemoryUsagePolicy::Strict))
- return MemoryUsagePolicy::Strict;
- if (footprint >= thresholdForPolicy(MemoryUsagePolicy::Conservative))
- return MemoryUsagePolicy::Conservative;
- return MemoryUsagePolicy::Unrestricted;
-}
-
-void MemoryPressureHandler::measurementTimerFired()
-{
- auto footprint = memoryFootprint();
- if (!footprint)
- return;
-
- RELEASE_LOG(MemoryPressure, "Current memory footprint: %lu MB", footprint.value() / MB);
-
- auto newPolicy = policyForFootprint(footprint.value());
- if (newPolicy == m_memoryUsagePolicy) {
- if (m_memoryUsagePolicy != MemoryUsagePolicy::Panic)
- return;
- RELEASE_LOG(MemoryPressure, "Memory usage still above panic threshold");
- } else
- RELEASE_LOG(MemoryPressure, "Memory usage policy changed: %s -> %s", toString(m_memoryUsagePolicy), toString(newPolicy));
-
- m_memoryUsagePolicy = newPolicy;
-
- if (newPolicy == MemoryUsagePolicy::Unrestricted)
- return;
-
- if (newPolicy == MemoryUsagePolicy::Conservative) {
- // FIXME: Implement this policy by choosing which caches should respect it, and hooking them up.
- return;
- }
-
- if (newPolicy == MemoryUsagePolicy::Strict) {
- RELEASE_LOG(MemoryPressure, "Attempting to reduce memory footprint by freeing less important objects.");
- releaseMemory(Critical::No, Synchronous::No);
- return;
- }
-
- RELEASE_ASSERT(newPolicy == MemoryUsagePolicy::Panic);
-
- RELEASE_LOG(MemoryPressure, "Attempting to reduce memory footprint by freeing more important objects.");
- if (m_processIsEligibleForMemoryKillCallback) {
- if (!m_processIsEligibleForMemoryKillCallback()) {
- releaseMemory(Critical::Yes, Synchronous::No);
- return;
- }
- }
-
- releaseMemory(Critical::Yes, Synchronous::Yes);
-
- // Remeasure footprint to see how well the pressure handler did.
- footprint = memoryFootprint();
- RELEASE_ASSERT(footprint);
-
- RELEASE_LOG(MemoryPressure, "New memory footprint: %lu MB", footprint.value() / MB);
- if (footprint.value() < thresholdForPolicy(MemoryUsagePolicy::Panic)) {
- m_memoryUsagePolicy = policyForFootprint(footprint.value());
- RELEASE_LOG(MemoryPressure, "Pressure reduced below panic threshold. New memory usage policy: %s", toString(m_memoryUsagePolicy));
- return;
- }
-
- if (m_memoryKillCallback)
- m_memoryKillCallback();
-}
-
void MemoryPressureHandler::beginSimulatedMemoryPressure()
{
m_isSimulatingMemoryPressure = true;
#include <wtf/Forward.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/Optional.h>
-#include <wtf/RunLoop.h>
#if PLATFORM(IOS)
#include <wtf/Lock.h>
#include <wtf/ThreadingPrimitives.h>
-#endif
-
+#elif OS(LINUX)
+#include <wtf/RunLoop.h>
#if USE(GLIB)
#include <wtf/glib/GRefPtr.h>
#endif
+#endif
namespace WebCore {
};
#endif
-enum class MemoryUsagePolicy {
- Unrestricted, // Allocate as much as you want
- Conservative, // Maybe you don't cache every single thing
- Strict, // Time to start pinching pennies for real
- Panic, // OH GOD WE'RE SINKING, THROW EVERYTHING OVERBOARD
-};
-
enum class Critical { No, Yes };
enum class Synchronous { No, Yes };
WEBCORE_EXPORT void install();
- WEBCORE_EXPORT void setShouldUsePeriodicMemoryMonitor(bool);
-
- void setMemoryKillCallback(WTF::Function<void()> function) { m_memoryKillCallback = WTFMove(function); }
- void setProcessIsEligibleForMemoryKillCallback(WTF::Function<bool()> function) { m_processIsEligibleForMemoryKillCallback = WTFMove(function); }
-
void setLowMemoryHandler(LowMemoryHandler&& handler)
{
m_lowMemoryHandler = WTFMove(handler);
}
- bool isUnderMemoryPressure() const
- {
- return m_underMemoryPressure
-#if PLATFORM(MAC)
- || m_memoryUsagePolicy >= MemoryUsagePolicy::Strict
-#endif
- || m_isSimulatingMemoryPressure;
- }
+ bool isUnderMemoryPressure() const { return m_underMemoryPressure || m_isSimulatingMemoryPressure; }
void setUnderMemoryPressure(bool b) { m_underMemoryPressure = b; }
#if PLATFORM(IOS)
void respondToMemoryPressure(Critical, Synchronous = Synchronous::No);
void platformReleaseMemory(Critical);
- NO_RETURN_DUE_TO_CRASH void didExceedMemoryLimitAndFailedToRecover();
- void measurementTimerFired();
-
#if OS(LINUX)
class EventFDPoller {
WTF_MAKE_NONCOPYABLE(EventFDPoller); WTF_MAKE_FAST_ALLOCATED;
#endif
bool m_installed { false };
+ time_t m_lastRespondTime { 0 };
LowMemoryHandler m_lowMemoryHandler;
std::atomic<bool> m_underMemoryPressure;
bool m_isSimulatingMemoryPressure { false };
- RunLoop::Timer<MemoryPressureHandler> m_measurementTimer;
- MemoryUsagePolicy m_memoryUsagePolicy { MemoryUsagePolicy::Unrestricted };
- WTF::Function<void()> m_memoryKillCallback;
- WTF::Function<bool()> m_processIsEligibleForMemoryKillCallback;
-
#if PLATFORM(IOS)
// FIXME: Can we share more of this with OpenSource?
uint32_t m_memoryPressureReason { MemoryPressureReasonNone };
+2017-02-02 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r211571 and r211582.
+ https://bugs.webkit.org/show_bug.cgi?id=167751
+
+ This change caused API test WebKit1.MemoryPressureHandler to
+ fail with an assertion. (Requested by ryanhaddad on #webkit).
+
+ Reverted changesets:
+
+ "[Mac] In-process memory pressure monitor for WebContent
+ processes."
+ https://bugs.webkit.org/show_bug.cgi?id=167491
+ http://trac.webkit.org/changeset/211571
+
+ "Unreviewed attempt to fix the Windows build after r211571."
+ http://trac.webkit.org/changeset/211582
+
2017-02-02 Dan Bernstein <mitz@apple.com>
The Make Frameworks Symbolic Link build phase can end up creating a symlink inside the Frameworks subdirectory
memoryPressureHandler.setLowMemoryHandler([] (Critical critical, Synchronous synchronous) {
WebCore::releaseMemory(critical, synchronous);
});
-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
- memoryPressureHandler.setShouldUsePeriodicMemoryMonitor(true);
- memoryPressureHandler.setMemoryKillCallback([] () {
- WebCore::didExceedMemoryLimitAndFailedToRecover();
- });
- memoryPressureHandler.setProcessIsEligibleForMemoryKillCallback([] () {
- return WebCore::processIsEligibleForMemoryKill();
- });
-#endif
memoryPressureHandler.install();
}