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

Side by Side Diff: runtime/bin/process_android.cc

Issue 2994223002: Restore "Add current rss and embedder name to Observatory" (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/bin/process_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #if !defined(DART_IO_DISABLED) 5 #if !defined(DART_IO_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(HOST_OS_ANDROID) 8 #if defined(HOST_OS_ANDROID)
9 9
10 #include "bin/process.h" 10 #include "bin/process.h"
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 } 852 }
853 853
854 void Process::TerminateExitCodeHandler() { 854 void Process::TerminateExitCodeHandler() {
855 ExitCodeHandler::TerminateExitCodeThread(); 855 ExitCodeHandler::TerminateExitCodeThread();
856 } 856 }
857 857
858 intptr_t Process::CurrentProcessId() { 858 intptr_t Process::CurrentProcessId() {
859 return static_cast<intptr_t>(getpid()); 859 return static_cast<intptr_t>(getpid());
860 } 860 }
861 861
862 static void SaveErrorAndClose(FILE* file) {
863 int actual_errno = errno;
864 fclose(file);
865 errno = actual_errno;
866 }
867
862 int64_t Process::CurrentRSS() { 868 int64_t Process::CurrentRSS() {
863 // The second value in /proc/self/statm is the current RSS in pages. 869 // The second value in /proc/self/statm is the current RSS in pages.
864 File* statm = File::Open("/proc/self/statm", File::kRead); 870 // It is not possible to use getrusage() because the interested fields are not
871 // implemented by the linux kernel.
872 FILE* statm = fopen("/proc/self/statm", "r");
865 if (statm == NULL) { 873 if (statm == NULL) {
866 return -1; 874 return -1;
867 } 875 }
868 RefCntReleaseScope<File> releaser(statm); 876 int64_t current_rss_pages = 0;
869 const intptr_t statm_length = 1 * KB; 877 int matches = fscanf(statm, "%*s%" Pd64 "", &current_rss_pages);
870 void* buffer = reinterpret_cast<void*>(Dart_ScopeAllocate(statm_length)); 878 if (matches != 1) {
871 const intptr_t statm_read = statm->Read(buffer, statm_length); 879 SaveErrorAndClose(statm);
872 if (statm_read <= 0) {
873 return -1; 880 return -1;
874 } 881 }
875 int64_t current_rss_pages = 0; 882 fclose(statm);
876 int matches = sscanf(reinterpret_cast<char*>(buffer), "%*s%" Pd64 "",
877 &current_rss_pages);
878 if (matches != 1) {
879 return -1;
880 }
881 return current_rss_pages * getpagesize(); 883 return current_rss_pages * getpagesize();
882 } 884 }
883 885
884 int64_t Process::MaxRSS() { 886 int64_t Process::MaxRSS() {
885 struct rusage usage; 887 struct rusage usage;
886 usage.ru_maxrss = 0; 888 usage.ru_maxrss = 0;
887 int r = getrusage(RUSAGE_SELF, &usage); 889 int r = getrusage(RUSAGE_SELF, &usage);
888 if (r < 0) { 890 if (r < 0) {
889 return -1; 891 return -1;
890 } 892 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL)); 1001 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL));
1000 } 1002 }
1001 } 1003 }
1002 1004
1003 } // namespace bin 1005 } // namespace bin
1004 } // namespace dart 1006 } // namespace dart
1005 1007
1006 #endif // defined(HOST_OS_ANDROID) 1008 #endif // defined(HOST_OS_ANDROID)
1007 1009
1008 #endif // !defined(DART_IO_DISABLED) 1010 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/bin/process_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698