diff --git a/CHANGELOG.md b/CHANGELOG.md index 611464eb5..886a7e692 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Features: * Adds a `tempSensor` option to specify the sensor name used for CPU temperature detection (CPU) * Example: `{ "type": "cpu", "tempSensor": "hwmon0" /* Use /sys/class/hwmon/hwmon0 for temperature detection */ }` * Minor optimizations +* Reports usable RAM size to match other platforms (Memory, macOS) Bugfixes: * Fixes cache line size detection (CPU, macOS) diff --git a/src/detection/memory/memory_apple.c b/src/detection/memory/memory_apple.c index cabdab267..812def5e8 100644 --- a/src/detection/memory/memory_apple.c +++ b/src/detection/memory/memory_apple.c @@ -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;