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

Unified Diff: tools/ProcStats.cpp

Issue 990723002: DM: display current memory usage (instead of peak) when available. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: better best 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 | « tools/ProcStats.h ('k') | 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 c9f9f3f6c55d3da680faad2b659e2622a9b757f3..1af71917bd365bf917160e8aa82f2e6e9453c9f5 100644
--- a/tools/ProcStats.cpp
+++ b/tools/ProcStats.cpp
@@ -7,10 +7,7 @@
#include "ProcStats.h"
-#if defined(SK_BUILD_FOR_UNIX) || \
- defined(SK_BUILD_FOR_MAC) || \
- defined(SK_BUILD_FOR_ANDROID)
-
+#if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_ANDROID)
#include <sys/resource.h>
int sk_tools::getMaxResidentSetSizeMB() {
struct rusage ru;
@@ -21,7 +18,6 @@
return static_cast<int>(ru.ru_maxrss / 1024); // Linux reports kilobytes.
#endif
}
-
#elif defined(SK_BUILD_FOR_WIN32)
#include <windows.h>
#include <psapi.h>
@@ -30,10 +26,27 @@
GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info));
return static_cast<int>(info.PeakWorkingSetSize / 1024 / 1024); // Windows reports bytes.
}
-
#else
- int sk_tools::getMaxResidentSetSizeMB() {
- return -1;
- }
+ int sk_tools::getMaxResidentSetSizeMB() { return -1; }
+#endif
+#if defined(SK_BUILD_FOR_MAC)
+ #include <mach/mach.h>
+ int sk_tools::getCurrResidentSetSizeMB() {
+ mach_task_basic_info info;
+ mach_msg_type_number_t count = MACH_TASK_BASIC_INFO_COUNT;
+ if (KERN_SUCCESS !=
+ task_info(mach_task_self(), MACH_TASK_BASIC_INFO, (task_info_t)&info, &count)) {
+ return -1;
+ }
+ return info.resident_size / 1024 / 1024; // Darwin reports bytes.
+ }
+#elif defined(SK_BUILD_FOR_WIN32)
+ int sk_tools::getCurrResidentSetSizeMB() {
+ PROCESS_MEMORY_COUNTERS info;
+ GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info));
+ return static_cast<int>(info.WorkingSetSize / 1024 / 1024); // Windows reports bytes.
+ }
+#else
hal.canary 2015/03/16 17:22:34 #ifdef __linux #include <unistd.h> #includ
+ int sk_tools::getCurrResidentSetSizeMB() { return -1; }
#endif
« no previous file with comments | « tools/ProcStats.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698