OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/renderer_host/render_process_host.h" | 5 #include "chrome/browser/renderer_host/render_process_host.h" |
6 | 6 |
7 #include "base/rand_util.h" | 7 #include "base/rand_util.h" |
8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
9 #include "chrome/common/chrome_constants.h" | 9 #include "chrome/common/chrome_constants.h" |
10 #include "chrome/common/notification_service.h" | 10 #include "chrome/common/notification_service.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 unsigned int GetMaxRendererProcessCount() { | 14 unsigned int GetMaxRendererProcessCount() { |
15 // Defines the maximum number of renderer processes according to the | 15 // Defines the maximum number of renderer processes according to the amount |
16 // amount of installed memory as reported by the OS. The table | 16 // of installed memory as reported by the OS. The table values are calculated |
17 // values are calculated by assuming that you want the renderers to | 17 // by assuming that you want the renderers to use half of the installed ram |
18 // use half of the installed ram and assuming that each tab uses | 18 // and assuming that each tab uses ~25MB. |
19 // ~25MB. | |
20 static const int kMaxRenderersByRamTier[] = { | 19 static const int kMaxRenderersByRamTier[] = { |
21 4, // less than 256MB | 20 4, // less than 256MB |
22 8, // 256MB | 21 8, // 256MB |
23 12, // 512MB | 22 12, // 512MB |
24 16, // 768MB | 23 16, // 768MB |
25 }; | 24 }; |
26 | 25 |
27 static unsigned int max_count = 0; | 26 static unsigned int max_count = 0; |
28 if (!max_count) { | 27 if (!max_count) { |
29 size_t memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256; | 28 int memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256; |
30 if (memory_tier >= arraysize(kMaxRenderersByRamTier)) | 29 if (memory_tier >= arraysize(kMaxRenderersByRamTier)) |
31 max_count = chrome::kMaxRendererProcessCount; | 30 max_count = chrome::kMaxRendererProcessCount; |
32 else | 31 else |
33 max_count = kMaxRenderersByRamTier[memory_tier]; | 32 max_count = kMaxRenderersByRamTier[memory_tier]; |
34 } | 33 } |
35 return max_count; | 34 return max_count; |
36 } | 35 } |
37 | 36 |
38 // Returns true if the given host is suitable for launching a new view | 37 // Returns true if the given host is suitable for launching a new view |
39 // associated with the given profile. | 38 // associated with the given profile. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 150 |
152 return NULL; | 151 return NULL; |
153 } | 152 } |
154 | 153 |
155 void RenderProcessHost::Unregister() { | 154 void RenderProcessHost::Unregister() { |
156 if (host_id_ >= 0) { | 155 if (host_id_ >= 0) { |
157 all_hosts.Remove(host_id_); | 156 all_hosts.Remove(host_id_); |
158 host_id_ = -1; | 157 host_id_ = -1; |
159 } | 158 } |
160 } | 159 } |
OLD | NEW |