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

Unified Diff: tools/ProcStats.cpp

Issue 1009313003: Current RSS on linux and android too? (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: initialize Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/ProcStats.cpp
diff --git a/tools/ProcStats.cpp b/tools/ProcStats.cpp
index 1af71917bd365bf917160e8aa82f2e6e9453c9f5..5c41213d4df2513f9196adc1c747fe93f00123c4 100644
--- a/tools/ProcStats.cpp
+++ b/tools/ProcStats.cpp
@@ -41,6 +41,23 @@
}
return info.resident_size / 1024 / 1024; // Darwin reports bytes.
}
+#elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) // N.B. /proc is Linux-only.
+ #include <unistd.h>
+ #include <stdio.h>
+ int sk_tools::getCurrResidentSetSizeMB() {
+ const long pageSize = sysconf(_SC_PAGESIZE);
+ long rssPages = 0;
+ if (FILE* statm = fopen("/proc/self/statm", "r")) {
+ // statm contains: program-size rss shared text lib data dirty, all in page counts.
+ int rc = fscanf(statm, "%*d %ld", &rssPages);
+ fclose(statm);
+ if (rc != 1) {
+ return -1;
+ }
+ }
+ return rssPages * pageSize / 1024 / 1024;
+ }
+
#elif defined(SK_BUILD_FOR_WIN32)
int sk_tools::getCurrResidentSetSizeMB() {
PROCESS_MEMORY_COUNTERS info;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698