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

Unified Diff: base/sys_info_ios.mm

Issue 2766623002: Revert of Fix free memory calculation. (Closed)
Patch Set: Created 3 years, 9 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 | « base/sys_info.h ('k') | base/sys_info_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_ios.mm
diff --git a/base/sys_info_ios.mm b/base/sys_info_ios.mm
index 9a329b9f0924bbdefce908cd51de4a6488c574f0..9a95298e692d7bbf3fb124528f96d355b784d9d2 100644
--- a/base/sys_info_ios.mm
+++ b/base/sys_info_ios.mm
@@ -15,7 +15,6 @@
#include "base/mac/scoped_mach_port.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/macros.h"
-#include "base/process/process_metrics.h"
#include "base/strings/sys_string_conversions.h"
namespace base {
@@ -84,12 +83,19 @@
// static
int64_t SysInfo::AmountOfAvailablePhysicalMemory() {
- SystemMemoryInfoKB info;
- if (!GetSystemMemoryInfo(&info))
+ base::mac::ScopedMachSendRight host(mach_host_self());
+ vm_statistics_data_t vm_info;
+ mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
+ if (host_statistics(host.get(),
+ HOST_VM_INFO,
+ reinterpret_cast<host_info_t>(&vm_info),
+ &count) != KERN_SUCCESS) {
+ NOTREACHED();
return 0;
- // We should add inactive file-backed memory also but there is no such
- // information from iOS unfortunately.
- return static_cast<int64_t>(info.free + info.speculative) * 1024;
+ }
+
+ return static_cast<int64_t>(vm_info.free_count - vm_info.speculative_count) *
+ PAGE_SIZE;
}
// static
« no previous file with comments | « base/sys_info.h ('k') | base/sys_info_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698