File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8484#include " IgnoreOpensDuringUnloadCountIncrementer.h"
8585#include " InspectorController.h"
8686#include " InspectorInstrumentation.h"
87+ #include " LegacySchemeRegistry.h"
8788#include " LinkLoader.h"
8889#include " LoaderStrategy.h"
8990#include " LocalDOMWindow.h"
@@ -2237,7 +2238,8 @@ void FrameLoader::commitProvisionalLoad()
22372238 // We are doing this here because we know for sure that a new page is about to be loaded.
22382239 BackForwardCache::singleton ().addIfCacheable (*frame->history ().protectedCurrentItem (), frame->protectedPage ().get ());
22392240
2240- WebCore::jettisonExpensiveObjectsOnTopLevelNavigation ();
2241+ if (pdl && LegacySchemeRegistry::shouldLoadURLSchemeAsEmptyDocument (pdl->request ().url ().protocol ().toStringWithoutCopying ()))
2242+ WebCore::jettisonExpensiveObjectsOnTopLevelNavigation ();
22412243 }
22422244
22432245 if (m_loadType != FrameLoadType::Replace)
Original file line number Diff line number Diff line change @@ -262,7 +262,24 @@ void logMemoryStatistics(LogMemoryStatisticsReason reason)
262262void platformReleaseMemory (Critical) { }
263263#endif
264264void platformReleaseGraphicsMemory (Critical) { }
265- void jettisonExpensiveObjectsOnTopLevelNavigation () { }
265+ void jettisonExpensiveObjectsOnTopLevelNavigation ()
266+ {
267+ // based on code from cocoa/MemoryReleaseCocoa.mm
268+ // Protect against doing excessive jettisoning during repeated navigations.
269+ const auto minimumTimeSinceNavigation = std::chrono::seconds (2 );
270+
271+ const auto now = std::chrono::steady_clock::now ();
272+ static auto timeOfLastNavigation = now;
273+ const bool shouldJettison = (timeOfLastNavigation == now) || (std::chrono::duration_cast<std::chrono::seconds>(now - timeOfLastNavigation) >= minimumTimeSinceNavigation);
274+ timeOfLastNavigation = now;
275+
276+ if (!shouldJettison)
277+ return ;
278+
279+ RunLoop::main ().dispatch ([]{
280+ releaseMemory (Critical::Yes, Synchronous::Yes);
281+ });
282+ }
266283void registerMemoryReleaseNotifyCallbacks () { }
267284#endif
268285
You can’t perform that action at this time.
0 commit comments