1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/sys_info.h"
9 #include <sys/sysctl.h>
11 #include "base/logging.h"
15 int64_t SysInfo::AmountOfPhysicalMemoryImpl() {
17 size_t size = sizeof(pages);
18 sysctlbyname("vm.stats.vm.v_page_count", &pages, &size, NULL, 0);
19 sysctlbyname("vm.stats.vm.v_page_size", &page_size, &size, NULL, 0);
20 if (pages == -1 || page_size == -1) {
24 return static_cast<int64_t>(pages) * page_size;
28 uint64_t SysInfo::MaxSharedMemorySize() {
30 size_t size = sizeof(limit);
31 if (sysctlbyname("kern.ipc.shmmax", &limit, &size, NULL, 0) < 0) {
35 return static_cast<uint64_t>(limit);