Swap: add macOS support

This commit is contained in:
Carter Li
2022-09-17 11:21:05 +08:00
parent bd657328d2
commit 8c6cf2ccda
+8 -1
View File
@@ -1,9 +1,9 @@
#include "memory.h"
#include "common/settings.h"
#include <string.h>
#include <mach/mach.h>
#include <sys/sysctl.h>
void ffDetectMemoryImpl(FFMemoryResult* memory)
{
@@ -21,4 +21,11 @@ void ffDetectMemoryImpl(FFMemoryResult* memory)
return;
memory->ram.bytesUsed = ((uint64_t) vmstat.active_count + vmstat.wire_count) * pagesize;
struct xsw_usage swap;
size_t size = sizeof(swap);
if (sysctlbyname("vm.swapusage", &swap, &size, 0, 0) == -1)
return;
memory->swap.bytesTotal = swap.xsu_total;
memory->swap.bytesUsed = swap.xsu_used;
}