From e0e59d449513af8719da0984073ccac040d4d911 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Thu, 23 Mar 2023 17:50:54 -0700 Subject: [PATCH] grahhh --- source/funkin/utils/MemoryUtil.hx | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/source/funkin/utils/MemoryUtil.hx b/source/funkin/utils/MemoryUtil.hx index 47f4ab69..6974ee72 100644 --- a/source/funkin/utils/MemoryUtil.hx +++ b/source/funkin/utils/MemoryUtil.hx @@ -21,12 +21,11 @@ using StringTools; #endif #if defined(HX_MAC) - #include - #include + #include #endif #if defined(HX_LINUX) - #include + #include #endif ") #end @@ -88,18 +87,14 @@ class MemoryUtil { #endif #if defined(HX_MAC) - vm_size_t page_size; - host_page_size(mach_host_self(), &page_size); - vm_statistics64_data_t vm_stats; - mach_msg_type_number_t info_count = HOST_VM_INFO64_COUNT; - if (host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t)&vm_stats, &info_count) == KERN_SUCCESS) { - unsigned long long total_memory = ((unsigned long long)vm_stats.active_count + - (unsigned long long)vm_stats.inactive_count + - (unsigned long long)vm_stats.wire_count + - (unsigned long long)vm_stats.free_count) * (unsigned long long)page_size; + int mib [] = { CTL_HW, HW_MEMSIZE }; + int64_t value = 0; + size_t length = sizeof(value); - return total_memory / (1024*1024); - } + if(-1 == sysctl(mib, 2, &value, &length, NULL, 0)) + return -1; // An error occurred + + return value / 1024 / 1024; #endif #if defined(HX_LINUX)