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
+1
View File
@@ -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)
+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;