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

Side by Side Diff: content/browser/renderer_host/renderer_frame_manager.cc

Issue 1749073002: Do V8 GC ASAP if system memory is pressured (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/renderer_host/renderer_frame_manager.h" 5 #include "content/browser/renderer_host/renderer_frame_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: 90 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL:
91 percentage = kCriticalPressurePercentage; 91 percentage = kCriticalPressurePercentage;
92 break; 92 break;
93 } 93 }
94 size_t frames = (max_number_of_saved_frames_ * percentage) / 100; 94 size_t frames = (max_number_of_saved_frames_ * percentage) / 100;
95 return std::max(static_cast<size_t>(1), frames); 95 return std::max(static_cast<size_t>(1), frames);
96 } 96 }
97 97
98 RendererFrameManager::RendererFrameManager() 98 RendererFrameManager::RendererFrameManager()
99 : memory_pressure_listener_( 99 : memory_pressure_listener_(
100 base::Bind(&RendererFrameManager::OnMemoryPressure, 100 base::MemoryPressureListener::Create(base::Bind(
101 base::Unretained(this))) { 101 &RendererFrameManager::OnMemoryPressure, base::Unretained(this)))) {
102 // Note: With the destruction of this class the |memory_pressure_listener_| 102 // Note: With the destruction of this class the |memory_pressure_listener_|
103 // gets destroyed and the observer will remove itself. 103 // gets destroyed and the observer will remove itself.
104 max_number_of_saved_frames_ = 104 max_number_of_saved_frames_ =
105 #if defined(OS_ANDROID) 105 #if defined(OS_ANDROID)
106 1; 106 1;
107 #else 107 #else
108 std::min(5, 2 + (base::SysInfo::AmountOfPhysicalMemoryMB() / 256)); 108 std::min(5, 2 + (base::SysInfo::AmountOfPhysicalMemoryMB() / 256));
109 #endif 109 #endif
110 max_handles_ = base::SharedMemory::GetHandleLimit() / 8.0f; 110 max_handles_ = base::SharedMemory::GetHandleLimit() / 8.0f;
111 } 111 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 percentage = kCriticalPressurePercentage; 146 percentage = kCriticalPressurePercentage;
147 break; 147 break;
148 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: 148 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE:
149 // No need to change anything when there is no pressure. 149 // No need to change anything when there is no pressure.
150 return; 150 return;
151 } 151 }
152 CullUnlockedFrames(std::max(1, (saved_frame_limit * percentage) / 100)); 152 CullUnlockedFrames(std::max(1, (saved_frame_limit * percentage) / 100));
153 } 153 }
154 154
155 } // namespace content 155 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698