summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorSamuel Barney <samjbarney@gmail.com>2013-09-22 02:21:37 +0200
committerSamuel Barney <samjbarney@gmail.com>2013-09-22 02:21:37 +0200
commitadf84a05fa768a098bf383e00862f5fa91655fdd (patch)
tree3ff8f65629e37a62f71f1ca417b271dc0caab995 /source
parentPrepared cWebAdmin for Apple-specific GetMmeoryUsage() (diff)
downloadcuberite-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 '')
-rw-r--r--source/WebAdmin.cpp13
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;