diff options
author | Samuel Barney <samjbarney@gmail.com> | 2013-09-22 02:21:37 +0200 |
---|---|---|
committer | Samuel Barney <samjbarney@gmail.com> | 2013-09-22 02:21:37 +0200 |
commit | adf84a05fa768a098bf383e00862f5fa91655fdd (patch) | |
tree | 3ff8f65629e37a62f71f1ca417b271dc0caab995 /source | |
parent | Prepared cWebAdmin for Apple-specific GetMmeoryUsage() (diff) | |
download | cuberite-adf84a05fa768a098bf383e00862f5fa91655fdd.tar cuberite-adf84a05fa768a098bf383e00862f5fa91655fdd.tar.gz cuberite-adf84a05fa768a098bf383e00862f5fa91655fdd.tar.bz2 cuberite-adf84a05fa768a098bf383e00862f5fa91655fdd.tar.lz cuberite-adf84a05fa768a098bf383e00862f5fa91655fdd.tar.xz cuberite-adf84a05fa768a098bf383e00862f5fa91655fdd.tar.zst cuberite-adf84a05fa768a098bf383e00862f5fa91655fdd.zip |
Diffstat (limited to 'source')
-rw-r--r-- | source/WebAdmin.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/source/WebAdmin.cpp b/source/WebAdmin.cpp index 3931c8c89..65d50dbd9 100644 --- a/source/WebAdmin.cpp +++ b/source/WebAdmin.cpp @@ -21,7 +21,7 @@ #elif defined(__linux__) #include <fstream> #elif defined(__APPLE__) - // Apple-specific includes go here + #include <mach/mach.h> #endif @@ -451,7 +451,16 @@ int cWebAdmin::GetMemoryUsage(void) } return -1; #elif defined (__APPLE__) - // TODO: Apple-specific + struct task_basic_info t_info; + mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT; + + if (KERN_SUCCESS == task_info(mach_task_self(), + TASK_BASIC_INFO, (task_info_t)&t_info, + &t_info_count)) + { + return (int)(t_info.resident_size/1024); + } + return -1; #else LOGINFO("%s: Unknown platform, cannot query memory usage", __FUNCTION__); return -1; |