Changeset 87228 in webkit
- Timestamp:
- May 24, 2011 4:43:15 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 3 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r87227 r87228 1 2011-05-24 Michael Saboff <msaboff@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 Improve handling in WebCore of low memory situations 6 https://bugs.webkit.org/show_bug.cgi?id=61222 7 8 Added new class, MemoryPressureHandler, to platform to respond to low 9 system memory events. Added Mac specific implementation that reduces the 10 page cache, NSURL cache, WebCore cache by half their current usage 11 and then garbage collects. This can allow Safari to continue operating 12 in a low memory situation with minimal paging. 13 Split up prune operations in MemoryCache to allow for pruning to a 14 specific actual size to support this change. 15 16 No tests added as the functionality of WebKit wasn't changed. 17 18 * GNUmakefile.list.am: 19 * WebCore.exp.in: 20 * WebCore.gypi: 21 * WebCore.pro: 22 * WebCore.vcproj/WebCore.vcproj: 23 * WebCore.xcodeproj/project.pbxproj: 24 * loader/cache/MemoryCache.cpp: 25 (WebCore::MemoryCache::pruneLiveResources): 26 (WebCore::MemoryCache::forcePruneLiveResources): 27 (WebCore::MemoryCache::pruneLiveResourcesToTarget): 28 (WebCore::MemoryCache::pruneDeadResources): 29 (WebCore::MemoryCache::forcePruneDeadResources): 30 (WebCore::MemoryCache::pruneDeadResourcesToTarget): 31 * loader/cache/MemoryCache.h: 32 (WebCore::MemoryCache::forcePrune): 33 * platform/MemoryPressureHandler.cpp: Added. 34 (WebCore::memoryPressureHandler): 35 (WebCore::MemoryPressureHandler::MemoryPressureHandler): 36 (WebCore::MemoryPressureHandler::install): 37 (WebCore::MemoryPressureHandler::respondToMemoryPressure): 38 * platform/MemoryPressureHandler.h: Added. 39 * platform/mac/MemoryPressureHandler.mm: Added. 40 (WebCore::MemoryPressureHandler::install): 41 (WebCore::MemoryPressureHandler::respondToMemoryPressure): 42 1 43 2011-05-24 Kent Tamura <tkent@chromium.org> 2 44 -
trunk/Source/WebCore/GNUmakefile.list.am
r87197 r87228 2540 2540 Source/WebCore/platform/MIMETypeRegistry.cpp \ 2541 2541 Source/WebCore/platform/MIMETypeRegistry.h \ 2542 Source/WebCore/platform/MemoryPressureHandler.cpp \ 2543 Source/WebCore/platform/MemoryPressureHandler.h \ 2542 2544 Source/WebCore/platform/mock/DeviceOrientationClientMock.cpp \ 2543 2545 Source/WebCore/platform/mock/DeviceOrientationClientMock.h \ -
trunk/Source/WebCore/WebCore.exp.in
r87102 r87228 546 546 __ZN7WebCore20protocolIsJavaScriptERKN3WTF6StringE 547 547 __ZN7WebCore21BackForwardController11itemAtIndexEi 548 __ZN7WebCore21memoryPressureHandlerEv 549 __ZN7WebCore21MemoryPressureHandler7installEv 548 550 __ZN7WebCore21PlatformKeyboardEvent24disambiguateKeyDownEventENS0_4TypeEb 549 551 __ZN7WebCore21PlatformKeyboardEventC1EP7NSEvent -
trunk/Source/WebCore/WebCore.gypi
r87197 r87228 764 764 'platform/LocalizedStrings.h', 765 765 'platform/Logging.h', 766 'platform/MemoryPressureHandler.h', 766 767 'platform/MIMETypeRegistry.h', 767 768 'platform/NotImplemented.h', … … 3584 3585 'platform/LocalizedStrings.cpp', 3585 3586 'platform/Logging.cpp', 3587 'platform/MemoryPressureHandler.cpp', 3586 3588 'platform/MIMETypeRegistry.cpp', 3587 3589 'platform/Pasteboard.h', -
trunk/Source/WebCore/WebCore.pro
r87197 r87228 1022 1022 platform/LinkHash.cpp \ 1023 1023 platform/Logging.cpp \ 1024 platform/MemoryPressureHandler.cpp \ 1024 1025 platform/MIMETypeRegistry.cpp \ 1025 1026 platform/mock/DeviceOrientationClientMock.cpp \ … … 1998 1999 platform/Logging.h \ 1999 2000 platform/Language.h \ 2001 platfory/MemoryPressureHandler.h \ 2000 2002 platform/MIMETypeRegistry.h \ 2001 2003 platform/network/AuthenticationChallengeBase.h \ -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r87197 r87228 26095 26095 </File> 26096 26096 <File 26097 RelativePath="..\platform\MemoryPressureHandler.cpp" 26098 > 26099 </File> 26100 <File 26101 RelativePath="..\platform\MemoryPressureHandler.h" 26102 > 26103 </File> 26104 <File 26097 26105 RelativePath="..\platform\NotImplemented.h" 26098 26106 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r87197 r87228 1491 1491 656D37430ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D372B0ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1492 1492 656D37480ADBA5DE00A4554D /* SubresourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D37300ADBA5DE00A4554D /* SubresourceLoader.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1493 6571DCC81385E6A400702DD0 /* MemoryPressureHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 657EDA071385CB97004E0645 /* MemoryPressureHandler.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1494 657EDA081385CB97004E0645 /* MemoryPressureHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 657EDA061385CB97004E0645 /* MemoryPressureHandler.cpp */; }; 1495 657EDA0B1385CBD8004E0645 /* MemoryPressureHandlerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 657EDA0A1385CBD8004E0645 /* MemoryPressureHandlerMac.mm */; }; 1493 1496 6582A16309999D6D00BEEB6D /* SystemTimeMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6582A15509999D6D00BEEB6D /* SystemTimeMac.cpp */; }; 1494 1497 658436860AE01B7400E53753 /* FrameLoadRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 658436850AE01B7400E53753 /* FrameLoadRequest.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 8069 8072 656D372B0ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NetscapePlugInStreamLoader.h; sourceTree = "<group>"; }; 8070 8073 656D37300ADBA5DE00A4554D /* SubresourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SubresourceLoader.h; sourceTree = "<group>"; }; 8074 657EDA061385CB97004E0645 /* MemoryPressureHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryPressureHandler.cpp; sourceTree = "<group>"; }; 8075 657EDA071385CB97004E0645 /* MemoryPressureHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryPressureHandler.h; sourceTree = "<group>"; }; 8076 657EDA0A1385CBD8004E0645 /* MemoryPressureHandlerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryPressureHandlerMac.mm; sourceTree = "<group>"; }; 8071 8077 6582A15509999D6D00BEEB6D /* SystemTimeMac.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SystemTimeMac.cpp; sourceTree = "<group>"; }; 8072 8078 658436850AE01B7400E53753 /* FrameLoadRequest.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FrameLoadRequest.h; sourceTree = "<group>"; }; … … 14150 14156 BC25B528131C6D3900180E10 /* LocalizedStringsMac.mm */, 14151 14157 1402645D0AFDC19B005919E2 /* LoggingMac.mm */, 14158 657EDA0A1385CBD8004E0645 /* MemoryPressureHandlerMac.mm */, 14152 14159 BC772C5D0C4EB3440083285F /* MIMETypeRegistryMac.mm */, 14153 14160 A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */, … … 18634 18641 A8239DFE09B3CF8A00B60641 /* Logging.cpp */, 18635 18642 A8239DFF09B3CF8A00B60641 /* Logging.h */, 18643 657EDA061385CB97004E0645 /* MemoryPressureHandler.cpp */, 18644 657EDA071385CB97004E0645 /* MemoryPressureHandler.h */, 18636 18645 BC772C4C0C4EB3040083285F /* MIMETypeRegistry.cpp */, 18637 18646 BC772C4D0C4EB3040083285F /* MIMETypeRegistry.h */, … … 22921 22930 977E2E0F12F0FC9C00C13379 /* XSSFilter.h in Headers */, 22922 22931 FD537353137B651800008DCE /* ZeroPole.h in Headers */, 22932 6571DCC81385E6A400702DD0 /* MemoryPressureHandler.h in Headers */, 22923 22933 598365DD1355F557001B185D /* JSPositionCallback.h in Headers */, 22924 22934 598365DF1355F562001B185D /* JSPositionErrorCallback.h in Headers */, … … 25605 25615 977E2E0E12F0FC9C00C13379 /* XSSFilter.cpp in Sources */, 25606 25616 FD537352137B651800008DCE /* ZeroPole.cpp in Sources */, 25617 657EDA081385CB97004E0645 /* MemoryPressureHandler.cpp in Sources */, 25618 657EDA0B1385CBD8004E0645 /* MemoryPressureHandlerMac.mm in Sources */, 25607 25619 598365E41355F604001B185D /* JSPositionCallback.cpp in Sources */, 25608 25620 598365E61355F60D001B185D /* JSPositionErrorCallback.cpp in Sources */, -
trunk/Source/WebCore/loader/cache/MemoryCache.cpp
r84930 r87228 173 173 174 174 unsigned targetSize = static_cast<unsigned>(capacity * cTargetPrunePercentage); // Cut by a percentage to avoid immediately pruning again. 175 176 pruneLiveResourcesToSize(targetSize); 177 } 178 179 void MemoryCache::PruneLiveResourcesToPercentage(float prunePercentage) 180 { 181 if (!m_pruneEnabled) 182 return; 183 184 if (prunePercentage < 0.0f || prunePercentage > 0.95f) 185 return; 186 187 unsigned currentSize = m_liveSize + m_deadSize; 188 unsigned targetSize = static_cast<unsigned>(currentSize * prunePercentage); 189 190 pruneLiveResourcesToSize(targetSize); 191 } 192 193 void MemoryCache::pruneLiveResourcesToSize(unsigned targetSize) 194 { 175 195 double currentTime = FrameView::currentPaintTimeStamp(); 176 196 if (!currentTime) // In case prune is called directly, outside of a Frame paint. … … 217 237 218 238 unsigned targetSize = static_cast<unsigned>(capacity * cTargetPrunePercentage); // Cut by a percentage to avoid immediately pruning again. 239 pruneDeadResourcesToSize(targetSize); 240 } 241 242 void MemoryCache::PruneDeadResourcesToPercentage(float prunePercentage) 243 { 244 if (!m_pruneEnabled) 245 return; 246 247 if (prunePercentage < 0.0f || prunePercentage > 0.95f) 248 return; 249 250 unsigned currentSize = m_liveSize + m_deadSize; 251 unsigned targetSize = static_cast<unsigned>(currentSize * prunePercentage); 252 253 pruneDeadResourcesToSize(targetSize); 254 } 255 256 void MemoryCache::pruneDeadResourcesToSize(unsigned targetSize) 257 { 219 258 int size = m_allResources.size(); 220 259 221 260 if (!m_inPruneDeadResources) { 222 261 // See if we have any purged resources we can evict. -
trunk/Source/WebCore/loader/cache/MemoryCache.h
r86325 r87228 140 140 } 141 141 142 void pruneToPercentage(float targetPercentLive) 143 { 144 PruneDeadResourcesToPercentage(targetPercentLive); // Prune dead first, in case it was "borrowing" capacity from live. 145 PruneLiveResourcesToPercentage(targetPercentLive); 146 } 147 142 148 void setDeadDecodedDataDeletionInterval(double interval) { m_deadDecodedDataDeletionInterval = interval; } 143 149 double deadDecodedDataDeletionInterval() const { return m_deadDecodedDataDeletionInterval; } … … 183 189 unsigned liveCapacity() const; 184 190 unsigned deadCapacity() const; 185 186 void pruneDeadResources(); // Flush decoded and encoded data from resources not referenced by Web pages. 187 void pruneLiveResources(); // Flush decoded data from resources still referenced by Web pages. 191 192 // pruneDead*() - Flush decoded and encoded data from resources not referenced by Web pages. 193 // pruneLive*() - Flush decoded data from resources still referenced by Web pages. 194 void pruneDeadResources(); // Automatically decide how much to prune. 195 void pruneLiveResources(); 196 void PruneDeadResourcesToPercentage(float prunePercentage); 197 void PruneLiveResourcesToPercentage(float prunePercentage); 198 void pruneDeadResourcesToSize(unsigned targetSize); 199 void pruneLiveResourcesToSize(unsigned targetSize); 188 200 189 201 bool makeResourcePurgeable(CachedResource*); -
trunk/Source/WebKit/mac/ChangeLog
r87213 r87228 1 2011-05-24 Michael Saboff <msaboff@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 Improve handling in WebCore of low memory situations 6 https://bugs.webkit.org/show_bug.cgi?id=61222 7 8 Added call to enable memory pressure handling. 9 10 * WebView/WebView.mm: 11 (-[WebView _commonInitializationWithFrameName:groupName:usesDocumentViews:]): 12 * WebView/WebViewInternal.h: 13 1 14 2011-05-24 Jay Civelli <jcivelli@chromium.org> 2 15 -
trunk/Source/WebKit/mac/WebView/WebView.mm
r86415 r87228 139 139 #import <WebCore/JSNodeList.h> 140 140 #import <WebCore/Logging.h> 141 #import <WebCore/MemoryPressureHandler.h> 141 142 #import <WebCore/MIMETypeRegistry.h> 142 143 #import <WebCore/NodeList.h> … … 799 800 [[self preferences] _postPreferencesChangedAPINotification]; 800 801 802 memoryPressureHandler().install(); 803 801 804 if (!WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_LOCAL_RESOURCE_SECURITY_RESTRICTION)) { 802 805 // Originally, we allowed all local loads. -
trunk/Source/WebKit2/ChangeLog
r87221 r87228 1 2011-05-24 Michael Saboff <msaboff@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 Improve handling in WebCore of low memory situations 6 https://bugs.webkit.org/show_bug.cgi?id=61222 7 8 Added call to enable memory pressure handling for Mac case. 9 10 * WebProcess/WebProcess.cpp: 11 (WebKit::WebProcess::initializeWebProcess): 12 * WebProcess/WebProcess.h: 13 * WebProcess/mac/WebProcessMac.mm: 14 (WebKit::WebProcess::platformInitializeWebProcess): 15 1 16 2011-05-24 Brady Eidson <beidson@apple.com> 2 17 -
trunk/Source/WebKit2/WebProcess/WebProcess.cpp
r86967 r87228 59 59 #include <WebCore/Logging.h> 60 60 #include <WebCore/MemoryCache.h> 61 #include <WebCore/MemoryPressureHandler.h> 61 62 #include <WebCore/Page.h> 62 63 #include <WebCore/PageCache.h> … … 164 165 165 166 platformInitializeWebProcess(parameters, arguments); 167 168 memoryPressureHandler().install(); 166 169 167 170 RefPtr<APIObject> injectedBundleInitializationUserData;
Note: See TracChangeset
for help on using the changeset viewer.