File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8383#include " IgnoreOpensDuringUnloadCountIncrementer.h"
8484#include " InspectorController.h"
8585#include " InspectorInstrumentation.h"
86+ #include " LegacySchemeRegistry.h"
8687#include " LinkLoader.h"
8788#include " LoaderStrategy.h"
8889#include " LocalDOMWindow.h"
@@ -2226,7 +2227,8 @@ void FrameLoader::commitProvisionalLoad()
22262227 // We are doing this here because we know for sure that a new page is about to be loaded.
22272228 BackForwardCache::singleton ().addIfCacheable (*frame->history ().protectedCurrentItem (), frame->protectedPage ().get ());
22282229
2229- WebCore::jettisonExpensiveObjectsOnTopLevelNavigation ();
2230+ if (pdl && LegacySchemeRegistry::shouldLoadURLSchemeAsEmptyDocument (pdl->request ().url ().protocol ().toStringWithoutCopying ()))
2231+ WebCore::jettisonExpensiveObjectsOnTopLevelNavigation ();
22302232 }
22312233
22322234 if (m_loadType != FrameLoadType::Replace)
Original file line number Diff line number Diff line change @@ -253,7 +253,24 @@ void logMemoryStatistics(LogMemoryStatisticsReason reason)
253253void platformReleaseMemory (Critical) { }
254254#endif
255255void platformReleaseGraphicsMemory (Critical) { }
256- void jettisonExpensiveObjectsOnTopLevelNavigation () { }
256+ void jettisonExpensiveObjectsOnTopLevelNavigation ()
257+ {
258+ // based on code from cocoa/MemoryReleaseCocoa.mm
259+ // Protect against doing excessive jettisoning during repeated navigations.
260+ const auto minimumTimeSinceNavigation = std::chrono::seconds (2 );
261+
262+ const auto now = std::chrono::steady_clock::now ();
263+ static auto timeOfLastNavigation = now;
264+ const bool shouldJettison = (timeOfLastNavigation == now) || (std::chrono::duration_cast<std::chrono::seconds>(now - timeOfLastNavigation) >= minimumTimeSinceNavigation);
265+ timeOfLastNavigation = now;
266+
267+ if (!shouldJettison)
268+ return ;
269+
270+ RunLoop::main ().dispatch ([]{
271+ releaseMemory (Critical::Yes, Synchronous::Yes);
272+ });
273+ }
257274void registerMemoryReleaseNotifyCallbacks () { }
258275#endif
259276
You can’t perform that action at this time.
0 commit comments