Chromium Code Reviews| Index: base/sys_info_linux.cc |
| diff --git a/base/sys_info_linux.cc b/base/sys_info_linux.cc |
| index acc477134cd38bed2ba37e6add9f84370bfc87ca..8237d1050d3f62a8fcc4e489fc2c2ae9762ea2d8 100644 |
| --- a/base/sys_info_linux.cc |
| +++ b/base/sys_info_linux.cc |
| @@ -28,7 +28,13 @@ namespace base { |
| // static |
| int64 SysInfo::AmountOfPhysicalMemory() { |
| - return AmountOfMemory(_SC_PHYS_PAGES); |
| + static int64 physical_memory; |
| + static bool physical_memory_valid = false; |
| + if (!physical_memory_valid) { |
|
jar (doing other things)
2013/10/18 19:24:14
I'm hopeful this is done on only one thread... as
jln (very slow on Chromium)
2013/10/18 21:08:42
Should we just use LazyInstance these things? It's
jar (doing other things)
2013/10/18 22:19:30
+1. If in doubt about multi-threading, I'd rather
|
| + physical_memory = AmountOfMemory(_SC_PHYS_PAGES); |
| + physical_memory_valid = true; |
| + } |
| + return physical_memory; |
| } |
| // static |