Ответ 1
Вы можете использовать вызов Маха host_info(host, flavor, host_info, host_info_count)
. Если вы вызываете его с помощью flavor=HOST_BASIC_INFO
, то буфер host_info
указывает на заполнение struct host_basic_info
, что выглядит следующим образом:
struct host_basic_info {
integer_t max_cpus; /* max number of CPUs possible */
integer_t avail_cpus; /* number of CPUs now available */
natural_t memory_size; /* size of memory in bytes, capped at 2 GB */
cpu_type_t cpu_type; /* cpu type */
cpu_subtype_t cpu_subtype; /* cpu subtype */
cpu_threadtype_t cpu_threadtype; /* cpu threadtype */
integer_t physical_cpu; /* number of physical CPUs now available */
integer_t physical_cpu_max; /* max number of physical CPUs possible */
integer_t logical_cpu; /* number of logical cpu now available */
integer_t logical_cpu_max; /* max number of physical CPUs possible */
uint64_t max_mem; /* actual size of physical memory */
}
Из этой структуры вы можете получить размер памяти.