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

Unified Diff: runtime/bin/process_android.cc

Issue 2996803002: Add current rss and embedder name to Observatory (Closed)
Patch Set: Managing null currentRSS in graph tooltip Created 3 years, 4 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_android.cc
diff --git a/runtime/bin/process_android.cc b/runtime/bin/process_android.cc
index 66fc280523091c99fa593a120e872a8b9738e42e..ee9fb0ccda9f96072ff65dd3e2c05f78fd29c3d8 100644
--- a/runtime/bin/process_android.cc
+++ b/runtime/bin/process_android.cc
@@ -861,20 +861,16 @@ intptr_t Process::CurrentProcessId() {
int64_t Process::CurrentRSS() {
// The second value in /proc/self/statm is the current RSS in pages.
- File* statm = File::Open("/proc/self/statm", File::kRead);
+ // It is not possible to use getrusage() because the interested fields are not
+ // implemented by the linux kernel.
+ FILE* statm = fopen("/proc/self/statm", "r");
if (statm == NULL) {
return -1;
}
- RefCntReleaseScope<File> releaser(statm);
- const intptr_t statm_length = 1 * KB;
- void* buffer = reinterpret_cast<void*>(Dart_ScopeAllocate(statm_length));
- const intptr_t statm_read = statm->Read(buffer, statm_length);
- if (statm_read <= 0) {
- return -1;
- }
int64_t current_rss_pages = 0;
- int matches = sscanf(reinterpret_cast<char*>(buffer), "%*s%" Pd64 "",
+ int matches = fscanf(statm, "%*s%" Pd64 "",
&current_rss_pages);
zra 2017/08/10 22:19:50 It looks like this will fit on the line above.
cbernaschina 2017/08/12 00:29:42 Done.
+ fclose(statm);
zra 2017/08/10 22:19:50 This will blow away errno from fscanf when there i
cbernaschina 2017/08/10 22:40:28 If matches is 1 it means that the value was succes
zra 2017/08/10 22:49:47 If this function returns -1, the caller will make
cbernaschina 2017/08/12 00:29:42 Done.
if (matches != 1) {
return -1;
}

Powered by Google App Engine
This is Rietveld 408576698