Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 1780523002: Don't do V8 GC on memory pressure notifications in visible renderers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 2002 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 2013
2014 // Do not call into blink if it is not initialized. 2014 // Do not call into blink if it is not initialized.
2015 if (blink_platform_impl_) { 2015 if (blink_platform_impl_) {
2016 blink::WebMemoryPressureListener::onMemoryPressure( 2016 blink::WebMemoryPressureListener::onMemoryPressure(
2017 static_cast<blink::WebMemoryPressureLevel>(memory_pressure_level)); 2017 static_cast<blink::WebMemoryPressureLevel>(memory_pressure_level));
2018 2018
2019 if (blink::mainThreadIsolate()) { 2019 if (blink::mainThreadIsolate()) {
2020 // Trigger full v8 garbage collection on memory pressure notifications. 2020 // Trigger full v8 garbage collection on memory pressure notifications.
2021 // This will potentially hang the renderer for a long time, however, when 2021 // This will potentially hang the renderer for a long time, however, when
2022 // we receive a memory pressure notification, we might be about to be 2022 // we receive a memory pressure notification, we might be about to be
2023 // killed. 2023 // killed. Because of the janky hang don't do this to foreground
2024 blink::mainThreadIsolate()->LowMemoryNotification(); 2024 // renderers.
2025 RenderThread::Get()->PostTaskToAllWebWorkers( 2025 if (RendererIsHidden()) {
2026 base::Bind(&LowMemoryNotificationOnThisThread)); 2026 blink::mainThreadIsolate()->LowMemoryNotification();
2027 RenderThread::Get()->PostTaskToAllWebWorkers(
2028 base::Bind(&LowMemoryNotificationOnThisThread));
2029 }
2027 } 2030 }
2028 2031
2029 if (memory_pressure_level == 2032 if (memory_pressure_level ==
2030 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { 2033 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
2031 // Purge Skia font cache, by setting it to 0 and then again to the 2034 // Purge Skia font cache, by setting it to 0 and then again to the
2032 // previous limit. 2035 // previous limit.
2033 size_t font_cache_limit = SkGraphics::SetFontCacheLimit(0); 2036 size_t font_cache_limit = SkGraphics::SetFontCacheLimit(0);
2034 SkGraphics::SetFontCacheLimit(font_cache_limit); 2037 SkGraphics::SetFontCacheLimit(font_cache_limit);
2035 } 2038 }
2036 } 2039 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 } 2177 }
2175 2178
2176 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { 2179 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() {
2177 size_t erased = 2180 size_t erased =
2178 RenderThreadImpl::current()->pending_render_frame_connects_.erase( 2181 RenderThreadImpl::current()->pending_render_frame_connects_.erase(
2179 routing_id_); 2182 routing_id_);
2180 DCHECK_EQ(1u, erased); 2183 DCHECK_EQ(1u, erased);
2181 } 2184 }
2182 2185
2183 } // namespace content 2186 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698