Skip to content

Commit 94941da

Browse files
committed
Memory (macOS): uses hw.memsize_usable
1 parent 2bbd723 commit 94941da

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Features:
55
* Adds a `tempSensor` option to specify the sensor name used for CPU temperature detection (CPU)
66
* Example: `{ "type": "cpu", "tempSensor": "hwmon0" /* Use /sys/class/hwmon/hwmon0 for temperature detection */ }`
77
* Minor optimizations
8+
* Reports usable RAM size to match other platforms (Memory, macOS)
89

910
Bugfixes:
1011
* Fixes cache line size detection (CPU, macOS)

src/detection/memory/memory_apple.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
const char* ffDetectMemory(FFMemoryResult* ram)
99
{
1010
size_t length = sizeof(ram->bytesTotal);
11-
if (sysctl((int[]){ CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0))
12-
return "Failed to read hw.memsize";
11+
if (sysctlbyname("hw.memsize_usable", &ram->bytesTotal, &length, NULL, 0) != 0)
12+
{
13+
if (sysctl((int[]){ CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0) != 0)
14+
return "Failed to read hw.memsize";
15+
}
1316

1417
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
1518
vm_statistics64_data_t vmstat;

0 commit comments

Comments
 (0)