Determine physical mem size programmatically on OSX

前端 未结 4 1207
天命终不由人
天命终不由人 2020-12-29 14:33

We\'re trying to find out how much physical memory is installed in a machine running Mac OS X. We\'ve found the BSD function sysctl(). The problem is this function wants to

4条回答
  •  我在风中等你
    2020-12-29 15:13

    Alternatively you can add the data from vm_statistics_data_t to get the total memory

    vm_statistics_data_t vm_stat;
    int count = HOST_VM_INFO_COUNT;
    kern_return_t kernReturn = host_statistics(mach_host_self(), HOST_VM_INFO, (integer_t*)&vm_stat, (mach_msg_type_number_t*)&count);
    

提交回复
热议问题