Memory (macOS): uses hw.memsize_usable

This commit is contained in:
李通洲
2025-12-16 10:41:15 +08:00
parent 2bbd723321
commit 94941daf4f
2 changed files with 6 additions and 2 deletions
+5 -2
View File
@@ -8,8 +8,11 @@
const char* ffDetectMemory(FFMemoryResult* ram)
{
size_t length = sizeof(ram->bytesTotal);
if (sysctl((int[]){ CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0))
return "Failed to read hw.memsize";
if (sysctlbyname("hw.memsize_usable", &ram->bytesTotal, &length, NULL, 0) != 0)
{
if (sysctl((int[]){ CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0) != 0)
return "Failed to read hw.memsize";
}
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
vm_statistics64_data_t vmstat;