Changeset 43555 in vbox for trunk/src/VBox/Main/src-server/darwin
- Timestamp:
- Oct 5, 2012 11:23:42 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 81167
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/darwin/PerformanceDarwin.cpp
r28800 r43555 26 26 #include <iprt/log.h> 27 27 #include <iprt/param.h> 28 #include <iprt/system.h> 28 29 #include "Performance.h" 29 30 … … 74 75 CollectorDarwin::CollectorDarwin() 75 76 { 76 uint64_t hostMemory; 77 int mib[2]; 78 size_t size; 79 80 mib[0] = CTL_HW; 81 mib[1] = HW_MEMSIZE; 82 83 size = sizeof(hostMemory); 84 if (sysctl(mib, 2, &hostMemory, &size, NULL, 0) == -1) { 85 Log(("sysctl() -> %s", strerror(errno))); 86 hostMemory = 0; 87 } 88 totalRAM = (ULONG)(hostMemory / 1024); 77 uint64_t cb; 78 int rc = RTSystemQueryTotalRam(&cb); 79 if (RT_FAILED(rc)) 80 totalRAM = 0; 81 else 82 totalRAM = (ULONG)(cb / 1024); 89 83 } 90 84 … … 113 107 int CollectorDarwin::getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available) 114 108 { 115 kern_return_t krc; 116 mach_msg_type_number_t count; 117 vm_statistics_data_t info; 118 119 count = HOST_VM_INFO_COUNT; 120 121 krc = host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&info, &count); 122 if (krc != KERN_SUCCESS) 109 uint64_t cb; 110 int rc = RTSystemQueryAvailableRam(&cb); 111 if (RT_SUCCESS(rc)) 123 112 { 124 Log(("host_statistics() -> %s", mach_error_string(krc))); 125 return RTErrConvertFromDarwinKern(krc); 113 *total = totalRAM; 114 *available = cb / 1024; 115 *used = *total - *available; 126 116 } 127 128 *total = totalRAM; 129 *available = info.free_count * (PAGE_SIZE / 1024); 130 *used = *total - *available; 131 return VINF_SUCCESS; 117 return rc; 132 118 } 133 119
Note:
See TracChangeset
for help on using the changeset viewer.