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

Unified Diff: content/browser/renderer_host/renderer_frame_manager.cc

Issue 248193003: Limit renderer saved frames to avoid running out of fds. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/common/host_shared_bitmap_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/renderer_frame_manager.cc
diff --git a/content/browser/renderer_host/renderer_frame_manager.cc b/content/browser/renderer_host/renderer_frame_manager.cc
index 15c9814d61075f032ec5d3196f6eec2071c573d5..8ad31c42fb61609b8e435562acb93450573c22a2 100644
--- a/content/browser/renderer_host/renderer_frame_manager.cc
+++ b/content/browser/renderer_host/renderer_frame_manager.cc
@@ -7,7 +7,9 @@
#include <algorithm>
#include "base/logging.h"
+#include "base/memory/shared_memory.h"
#include "base/sys_info.h"
+#include "content/common/host_shared_bitmap_manager.h"
namespace content {
@@ -71,9 +73,23 @@ RendererFrameManager::RendererFrameManager() {
RendererFrameManager::~RendererFrameManager() {}
void RendererFrameManager::CullUnlockedFrames() {
+ uint32 saved_frame_limit = max_number_of_saved_frames();
+
+ if (saved_frame_limit > 2) {
+ // Reduce the number of saved frames to attempt to limit browser to using at
+ // most 1/8 of the available shared memory handles. This is only a soft
+ // limit, and it may go over as necessary.
+ const float kHandleMaxFraction = 1 / 8.0f;
+ float memory_handle_fraction =
+ HostSharedBitmapManager::current()->AllocatedBitmapCount() * 1.0f /
+ base::SharedMemory::GetHandleLimit();
+ float fraction_to_reduce =
+ std::min(1.0f, memory_handle_fraction / kHandleMaxFraction);
+ saved_frame_limit -=
+ static_cast<uint32>((saved_frame_limit - 2) * fraction_to_reduce);
piman 2014/04/23 00:32:02 I'm not sure I agree with this computation. If we'
+ }
piman 2014/04/23 00:32:02 RenderWidgetHostViewAuraTest.DiscardDelegatedFrame
while (!unlocked_frames_.empty() &&
- unlocked_frames_.size() + locked_frames_.size() >
- max_number_of_saved_frames()) {
+ unlocked_frames_.size() + locked_frames_.size() > saved_frame_limit) {
size_t old_size = unlocked_frames_.size();
// Should remove self from list.
unlocked_frames_.back()->EvictCurrentFrame();
« no previous file with comments | « no previous file | content/common/host_shared_bitmap_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698