summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/renderer_frame_manager.cc
diff options
context:
space:
mode:
authorjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-26 22:17:51 +0000
committerjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-26 22:17:51 +0000
commit2e8ac3a3d7bff018f9c47e03bd74fb3212f75392 (patch)
treea0bef2568276146c7c7fafa90b0720afb0d0ad53 /content/browser/renderer_host/renderer_frame_manager.cc
parent50675e03e192b012cf91ccbb6c2f2b25e7525ff6 (diff)
downloadchromium_src-2e8ac3a3d7bff018f9c47e03bd74fb3212f75392.zip
chromium_src-2e8ac3a3d7bff018f9c47e03bd74fb3212f75392.tar.gz
chromium_src-2e8ac3a3d7bff018f9c47e03bd74fb3212f75392.tar.bz2
Limit renderer saved frames to avoid running out of fds.
Software delegated rendering uses one fd per tile, so with a bunch of tiles that means it can run out of fds. If it seems close to hitting the limit the browser should throw away old frames to avoid this from happening. BUG=362603 Review URL: https://codereview.chromium.org/248193003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266383 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host/renderer_frame_manager.cc')
-rw-r--r--content/browser/renderer_host/renderer_frame_manager.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/content/browser/renderer_host/renderer_frame_manager.cc b/content/browser/renderer_host/renderer_frame_manager.cc
index 15c9814..0a93e298 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 {
@@ -66,14 +68,26 @@ RendererFrameManager::RendererFrameManager() {
#else
std::min(5, 2 + (base::SysInfo::AmountOfPhysicalMemoryMB() / 256));
#endif
+ max_handles_ = base::SharedMemory::GetHandleLimit() / 8.0f;
}
RendererFrameManager::~RendererFrameManager() {}
void RendererFrameManager::CullUnlockedFrames() {
+ uint32 saved_frame_limit = max_number_of_saved_frames();
+
+ if (unlocked_frames_.size() + locked_frames_.size() > 0) {
+ float handles_per_frame =
+ HostSharedBitmapManager::current()->AllocatedBitmapCount() * 1.0f /
+ (unlocked_frames_.size() + locked_frames_.size());
+
+ saved_frame_limit = std::max(
+ 1,
+ static_cast<int>(std::min(static_cast<float>(saved_frame_limit),
+ max_handles_ / handles_per_frame)));
+ }
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();