diff --git a/src/util.cpp b/src/util.cpp index a3342d4d..595eb1d1 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -64,6 +64,10 @@ #endif #endif +#ifdef __APPLE__ +#include +#endif + #include #include #include @@ -576,7 +580,13 @@ std::optional get_self_memory_usage() { #if defined(_WIN32) // TODO #elif defined(__APPLE__) - // TODO + mach_task_vm_info info{}; + mach_msg_type_number_t count = TASK_VM_INFO_COUNT; + + if (task_info(mach_task_self(), TASK_VM_INFO, + reinterpret_cast(&info), &count) == KERN_SUCCESS) { + return info.phys_footprint; + } #elif defined(__linux__) static constexpr auto kSmapsPath{"/proc/self/smaps_rollup"}; std::ifstream smaps(kSmapsPath);