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

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

Issue 2763933002: memory coordinator: Purge memory under memory pressure (Closed)
Patch Set: discard tab Created 3 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
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 2216 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 } 2227 }
2228 } 2228 }
2229 2229
2230 void RenderThreadImpl::OnMemoryStateChange(base::MemoryState state) { 2230 void RenderThreadImpl::OnMemoryStateChange(base::MemoryState state) {
2231 if (blink_platform_impl_) { 2231 if (blink_platform_impl_) {
2232 blink::WebMemoryCoordinator::onMemoryStateChange( 2232 blink::WebMemoryCoordinator::onMemoryStateChange(
2233 static_cast<blink::MemoryState>(state)); 2233 static_cast<blink::MemoryState>(state));
2234 } 2234 }
2235 } 2235 }
2236 2236
2237 void RenderThreadImpl::RecordPurgeMemory(RendererMemoryMetrics before) {
kinuko 2017/03/28 08:07:00 nit: please move this after OnPurgeMemory() (to ma
bashi 2017/03/28 09:37:17 Done.
2238 RendererMemoryMetrics after;
2239 GetRendererMemoryMetrics(&after);
2240 int64_t mbytes = static_cast<int64_t>(before.total_allocated_mb) -
2241 static_cast<int64_t>(after.total_allocated_mb);
2242 if (mbytes < 0)
2243 mbytes = 0;
2244 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Renderer.PurgedMemory",
2245 mbytes);
2246 }
2247
2237 void RenderThreadImpl::OnPurgeMemory() { 2248 void RenderThreadImpl::OnPurgeMemory() {
2249 RendererMemoryMetrics metrics;
2250 GetRendererMemoryMetrics(&metrics);
2251 GetRendererScheduler()->DefaultTaskRunner()->PostDelayedTask(
2252 FROM_HERE,
2253 base::Bind(&RenderThreadImpl::RecordPurgeMemory, base::Unretained(this),
2254 std::move(metrics)),
2255 base::TimeDelta::FromSeconds(2));
kinuko 2017/03/28 08:07:00 nit: Would be nice to have a short note about why
bashi 2017/03/28 09:37:17 Done.
2256
2238 OnTrimMemoryImmediately(); 2257 OnTrimMemoryImmediately();
2239 ReleaseFreeMemory(); 2258 ReleaseFreeMemory();
2240 ClearMemory(); 2259 ClearMemory();
2241 if (blink_platform_impl_) 2260 if (blink_platform_impl_)
2242 blink::WebMemoryCoordinator::onPurgeMemory(); 2261 blink::WebMemoryCoordinator::onPurgeMemory();
2243 } 2262 }
2244 2263
2245 void RenderThreadImpl::ClearMemory() { 2264 void RenderThreadImpl::ClearMemory() {
2246 // Do not call into blink if it is not initialized. 2265 // Do not call into blink if it is not initialized.
2247 if (blink_platform_impl_) { 2266 if (blink_platform_impl_) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2432 } 2451 }
2433 } 2452 }
2434 2453
2435 void RenderThreadImpl::OnRendererInterfaceRequest( 2454 void RenderThreadImpl::OnRendererInterfaceRequest(
2436 mojom::RendererAssociatedRequest request) { 2455 mojom::RendererAssociatedRequest request) {
2437 DCHECK(!renderer_binding_.is_bound()); 2456 DCHECK(!renderer_binding_.is_bound());
2438 renderer_binding_.Bind(std::move(request)); 2457 renderer_binding_.Bind(std::move(request));
2439 } 2458 }
2440 2459
2441 } // namespace content 2460 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698