Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1347)

Unified Diff: runtime/bin/process_macos.cc

Issue 2822943002: [dart:io] Adds ProcessInfo.{max,current}Rss. Adds OS::MaxRSS on Fuchsia. (Closed)
Patch Set: Fix Fuchsia build Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698