6 #include <mach/mach_error.h> 7 #include <mach/mach_host.h> 8 #include <mach/mach_init.h> 9 #include <mach/mach_types.h> 10 #include <mach/message.h> 29 mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
30 vm_statistics_data_t vmstat;
33 kern_return_t status1 = host_statistics(mach_host_self(), HOST_VM_INFO, reinterpret_cast<host_info_t>(&vmstat), &count);
34 kern_return_t status2 = host_page_size(mach_host_self(), &vmsize);
36 if (KERN_SUCCESS == status1 and KERN_SUCCESS == status2) {
38 used = vmstat.wire_count + vmstat.active_count + vmstat.inactive_count;
39 total = used + vmstat.free_count;
45 return (status1 == KERN_SUCCESS) ? status2 : status1;
55 memory_usage.
total = 1;
56 memory_usage.
used = 1;
61 return &this->m_handle;
MemoryHandle * getHandle() override
returns the raw console handle
PlatformSizeType FwSizeType
kern_return_t vm_stat_helper(FwSizeType &used, FwSizeType &total)
reads macOS virtual memory statistics for memory calculation
Status _getUsage(Os::Memory::Usage &memory_usage) override
get system memory usage
Status
Generic OK/ERROR status.
Memory variable handle parent.
FwSizeType total
Total amount.
FwSizeType used
Used amount.
Generic used/total struct.