Files
fastfetch/src/detection/memory/memory_bsd.c
T

19 lines
615 B
C
Raw Normal View History

2022-09-19 22:23:31 +02:00
#include "memory.h"
2022-09-19 23:16:43 +02:00
#include "common/sysctl.h"
2022-09-19 22:23:31 +02:00
2023-05-11 20:39:54 +08:00
const char* ffDetectMemory(FFMemoryResult* ram)
2022-09-19 22:23:31 +02:00
{
size_t length = sizeof(ram->bytesTotal);
if (sysctl((int[]){ CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0))
return "Failed to read hw.physmem";
// vm.stats.vm.* are int values
int32_t pagesFree = ffSysctlGetInt("vm.stats.vm.v_free_count", 0)
+ ffSysctlGetInt("vm.stats.vm.v_inactive_count", 0)
+ ffSysctlGetInt("vm.stats.vm.v_cache_count", 0);
2022-09-20 15:12:24 +02:00
2023-11-08 00:02:00 +08:00
ram->bytesUsed = ram->bytesTotal - (uint64_t) pagesFree * instance.state.platform.pageSize;
2023-05-11 20:39:54 +08:00
return NULL;
2022-09-20 15:12:24 +02:00
}