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

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

Issue 2763933002: memory coordinator: Purge memory under memory pressure (Closed)
Patch Set: Use int64_t 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 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 } 2223 }
2224 } 2224 }
2225 2225
2226 void RenderThreadImpl::OnMemoryStateChange(base::MemoryState state) { 2226 void RenderThreadImpl::OnMemoryStateChange(base::MemoryState state) {
2227 if (blink_platform_impl_) { 2227 if (blink_platform_impl_) {
2228 blink::WebMemoryCoordinator::onMemoryStateChange( 2228 blink::WebMemoryCoordinator::onMemoryStateChange(
2229 static_cast<blink::MemoryState>(state)); 2229 static_cast<blink::MemoryState>(state));
2230 } 2230 }
2231 } 2231 }
2232 2232
2233 void RenderThreadImpl::RecordPurgeMemory(RendererMemoryMetrics before) {
2234 RendererMemoryMetrics after;
2235 GetRendererMemoryMetrics(&after);
2236 int64_t mbytes = static_cast<int64_t>(before.total_allocated_mb) -
2237 static_cast<int64_t>(after.total_allocated_mb);
2238 if (mbytes < 0)
haraken 2017/03/24 11:55:39 Maybe we want to count this case in some way too?
bashi 2017/03/28 03:15:31 Done.
2239 return;
2240 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Renderer.PurgedMemory",
2241 mbytes);
2242 }
2243
2233 void RenderThreadImpl::OnPurgeMemory() { 2244 void RenderThreadImpl::OnPurgeMemory() {
2245 RendererMemoryMetrics metrics;
2246 GetRendererMemoryMetrics(&metrics);
2247 GetRendererScheduler()->DefaultTaskRunner()->PostDelayedTask(
2248 FROM_HERE,
2249 base::Bind(&RenderThreadImpl::RecordPurgeMemory, base::Unretained(this),
2250 std::move(metrics)),
2251 base::TimeDelta::FromSeconds(2));
haraken 2017/03/24 11:55:39 I guess tasak@ was using 15 seconds or something.
bashi 2017/03/28 03:15:31 I think 2 seconds is enough and 15 sec seems too l
2252
2234 OnTrimMemoryImmediately(); 2253 OnTrimMemoryImmediately();
2235 ReleaseFreeMemory(); 2254 ReleaseFreeMemory();
2236 ClearMemory(); 2255 ClearMemory();
2237 if (blink_platform_impl_) 2256 if (blink_platform_impl_)
2238 blink::WebMemoryCoordinator::onPurgeMemory(); 2257 blink::WebMemoryCoordinator::onPurgeMemory();
2239 } 2258 }
2240 2259
2241 void RenderThreadImpl::ClearMemory() { 2260 void RenderThreadImpl::ClearMemory() {
2242 // Do not call into blink if it is not initialized. 2261 // Do not call into blink if it is not initialized.
2243 if (blink_platform_impl_) { 2262 if (blink_platform_impl_) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2428 } 2447 }
2429 } 2448 }
2430 2449
2431 void RenderThreadImpl::OnRendererInterfaceRequest( 2450 void RenderThreadImpl::OnRendererInterfaceRequest(
2432 mojom::RendererAssociatedRequest request) { 2451 mojom::RendererAssociatedRequest request) {
2433 DCHECK(!renderer_binding_.is_bound()); 2452 DCHECK(!renderer_binding_.is_bound());
2434 renderer_binding_.Bind(std::move(request)); 2453 renderer_binding_.Bind(std::move(request));
2435 } 2454 }
2436 2455
2437 } // namespace content 2456 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698