Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "ui/gl/gl_context.h" | 5 #include "ui/gl/gl_context.h" |
| 6 | 6 |
| 7 #include "base/android/sys_utils.h" | 7 #include "base/android/sys_utils.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 // 128MB java heap size). First we estimate physical memory using both. | 98 // 128MB java heap size). First we estimate physical memory using both. |
| 99 size_t dalvik_mb = base::SysInfo::DalvikHeapSizeMB(); | 99 size_t dalvik_mb = base::SysInfo::DalvikHeapSizeMB(); |
| 100 size_t physical_mb = base::SysInfo::AmountOfPhysicalMemoryMB(); | 100 size_t physical_mb = base::SysInfo::AmountOfPhysicalMemoryMB(); |
| 101 size_t physical_memory_mb = 0; | 101 size_t physical_memory_mb = 0; |
| 102 if (dalvik_mb >= 256) | 102 if (dalvik_mb >= 256) |
| 103 physical_memory_mb = dalvik_mb * 4; | 103 physical_memory_mb = dalvik_mb * 4; |
| 104 else | 104 else |
| 105 physical_memory_mb = std::max(dalvik_mb * 4, | 105 physical_memory_mb = std::max(dalvik_mb * 4, |
| 106 (physical_mb * 4) / 3); | 106 (physical_mb * 4) / 3); |
| 107 | 107 |
| 108 // Now we take a default of 1/8th of memory on high-memory devices, | 108 // Now we take a default of 1/8th of memory on high-memory devices, |
|
aelias_OOO_until_Jul13
2014/02/15 00:55:17
I think we should include screen resolution as par
epenner
2014/02/15 01:02:27
If you look at the history of this code, we have g
| |
| 109 // and gradually scale that back for low-memory devices (to be nicer | 109 // and gradually scale that back for low-memory devices (to be nicer |
| 110 // to other apps so they don't get killed). Examples: | 110 // to other apps so they don't get killed). Examples: |
| 111 // Nexus 4/10(2GB) 256MB | 111 // Nexus 4/10(2GB) 256MB (normally 128MB) |
| 112 // Droid Razr M(1GB) 91MB | 112 // Droid Razr M(1GB) 114MB (normally 57MB) |
| 113 // Galaxy Nexus(1GB) 85MB | 113 // Galaxy Nexus(1GB) 100MB (normally 50MB) |
| 114 // Xoom(1GB) 85MB | 114 // Xoom(1GB) 100MB (normally 50MB) |
| 115 // Nexus S(low-end) 8MB | 115 // Nexus S(low-end) 12MB (normally 8MB) |
| 116 // Note that the compositor now uses only some of this memory for | |
| 117 // pre-painting and uses the rest only for 'emergencies'. | |
| 116 static size_t limit_bytes = 0; | 118 static size_t limit_bytes = 0; |
| 117 if (limit_bytes == 0) { | 119 if (limit_bytes == 0) { |
| 120 // NOTE: Non-low-end devices use only 50% of these limites, | |
|
aelias_OOO_until_Jul13
2014/02/15 00:55:17
typo: should be "limits"
epenner
2014/02/15 01:02:27
Done.
| |
| 121 // except during 'emergencies' where 100% can be used. | |
| 118 if (!base::android::SysUtils::IsLowEndDevice()) { | 122 if (!base::android::SysUtils::IsLowEndDevice()) { |
| 119 if (physical_memory_mb >= 1536) | 123 if (physical_memory_mb >= 1536) |
| 120 limit_bytes = physical_memory_mb / 8; | 124 limit_bytes = physical_memory_mb / 8; // >192MB |
| 121 else if (physical_memory_mb >= 1152) | 125 else if (physical_memory_mb >= 1152) |
| 122 limit_bytes = physical_memory_mb / 10; | 126 limit_bytes = physical_memory_mb / 8; // >144MB |
| 123 else if (physical_memory_mb >= 768) | 127 else if (physical_memory_mb >= 768) |
| 124 limit_bytes = physical_memory_mb / 12; | 128 limit_bytes = physical_memory_mb / 10; // >76MB |
| 125 else | 129 else |
| 126 limit_bytes = physical_memory_mb / 16; | 130 limit_bytes = physical_memory_mb / 12; // <64MB |
| 127 } else { | 131 } else { |
| 128 // Low-end devices have 512MB or less memory by definition | 132 // Low-end devices have 512MB or less memory by definition |
| 129 // so we hard code the limit rather than relying on the heuristics | 133 // so we hard code the limit rather than relying on the heuristics |
| 130 // above. Low-end devices use 4444 textures so we can use a lower limit. | 134 // above. Low-end devices use 4444 textures so we can use a lower limit. |
| 131 limit_bytes = 8; | 135 // NOTE: Low-end uses 2/3 (67%) of this memory in practice, so we have |
| 136 // increased the limit to 12 (8MB, or 12MB in emergencies). | |
| 137 limit_bytes = 12; | |
| 132 } | 138 } |
| 133 limit_bytes = limit_bytes * 1024 * 1024; | 139 limit_bytes = limit_bytes * 1024 * 1024; |
| 134 } | 140 } |
| 135 *bytes = limit_bytes; | 141 *bytes = limit_bytes; |
| 136 return true; | 142 return true; |
| 137 } | 143 } |
| 138 | 144 |
| 139 } | 145 } |
| OLD | NEW |