Index: runtime/bin/process_macos.cc |
diff --git a/runtime/bin/process_macos.cc b/runtime/bin/process_macos.cc |
index a4420d21251a36e2f4a5bcc0939356760a52ab53..6c0d451712f5bf8f2a48b82a945c9ff00430ce89 100644 |
--- a/runtime/bin/process_macos.cc |
+++ b/runtime/bin/process_macos.cc |
@@ -14,6 +14,7 @@ |
#endif |
#include <errno.h> // NOLINT |
#include <fcntl.h> // NOLINT |
+#include <mach/mach.h> // NOLINT |
#include <poll.h> // NOLINT |
#include <signal.h> // NOLINT |
#include <stdio.h> // NOLINT |
@@ -968,6 +969,30 @@ intptr_t Process::CurrentProcessId() { |
} |
+int64_t Process::CurrentRSS() { |
+ struct mach_task_basic_info info; |
+ mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT; |
+ kern_return_t result = |
+ task_info(mach_task_self(), MACH_TASK_BASIC_INFO, |
+ reinterpret_cast<task_info_t>(&info), &infoCount); |
+ if (result != KERN_SUCCESS) { |
+ return -1; |
+ } |
+ return info.resident_size; |
+} |
+ |
+ |
+int64_t Process::MaxRSS() { |
+ struct rusage usage; |
+ usage.ru_maxrss = 0; |
+ int r = getrusage(RUSAGE_SELF, &usage); |
+ if (r < 0) { |
+ return -1; |
+ } |
+ return usage.ru_maxrss; |
+} |
+ |
+ |
static Mutex* signal_mutex = new Mutex(); |
static SignalInfo* signal_handlers = NULL; |
static const int kSignalsCount = 7; |