I am trying to get the total amount of virtual memory on my system using the following code:
This doesn't work on MacOS 10.3.9, sysctl returns -1 and errno is set to ENOENT meaning: "The name array specifies a value that is unknown". Anyone run into this before?
Code:
//get the swap size
int vmmib[2] = {CTL_VM,VM_METER};
struct vmtotal myVirtualMemoryInfo;
size_t vmlen = sizeof(myVirtualMemoryInfo);
if (sysctl(vmmib, 2, &myVirtualMemoryInfo, &vmlen, NULL, NULL) == -1) {
fountainLog(QLOG_ERR, "Could not collect VM info, errno %d - %s", errno, strerror(errno));
result = FAILURE;
} else {
totalSWAP = myVirtualMemoryInfo.t_vm;
totalSWAP = static_cast<double>(totalSWAP) / 1024.0;
}
This doesn't work on MacOS 10.3.9, sysctl returns -1 and errno is set to ENOENT meaning: "The name array specifies a value that is unknown". Anyone run into this before?