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

Side by Side Diff: base/process_util_linux.cc

Issue 11345017: Create ash memory monitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make tray linux specific Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « base/process_util.h ('k') | chrome/app/generated_resources.grd » ('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 Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/process_util.h" 5 #include "base/process_util.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <malloc.h> 8 #include <malloc.h>
9 #include <sys/time.h> 9 #include <sys/time.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 // usually video memory otherwise invisible to the OS. Unfortunately, the 670 // usually video memory otherwise invisible to the OS. Unfortunately, the
671 // meminfo format varies on different hardware so we have to search for the 671 // meminfo format varies on different hardware so we have to search for the
672 // string. It always appears after "Cached:". 672 // string. It always appears after "Cached:".
673 for (size_t i = kMemCachedIndex+2; i < meminfo_fields.size(); i += 3) { 673 for (size_t i = kMemCachedIndex+2; i < meminfo_fields.size(); i += 3) {
674 if (meminfo_fields[i] == "Shmem:") { 674 if (meminfo_fields[i] == "Shmem:") {
675 base::StringToInt(meminfo_fields[i+1], &meminfo->shmem); 675 base::StringToInt(meminfo_fields[i+1], &meminfo->shmem);
676 break; 676 break;
677 } 677 }
678 } 678 }
679 #endif 679 #endif
680
681 // Check for gem data and report if present.
682 FilePath geminfo_file("/sys/kernel/debug/dri/0/i915_gem_objects");
683 std::string geminfo_data;
684 meminfo->gem_objects = -1;
685 meminfo->gem_size = -1;
686 if (file_util::ReadFileToString(geminfo_file, &geminfo_data)) {
687 int gem_objects = -1;
688 long long gem_size = -1;
689 int num_res = sscanf(geminfo_data.c_str(),
690 "%d objects, %lld bytes",
691 &gem_objects, &gem_size);
692 if (num_res == 2) {
693 meminfo->gem_objects = gem_objects;
694 meminfo->gem_size = gem_size;
695 }
696 }
697
680 return true; 698 return true;
681 } 699 }
682 700
683 size_t GetSystemCommitCharge() { 701 size_t GetSystemCommitCharge() {
684 SystemMemoryInfoKB meminfo; 702 SystemMemoryInfoKB meminfo;
685 if (!GetSystemMemoryInfo(&meminfo)) 703 if (!GetSystemMemoryInfo(&meminfo))
686 return 0; 704 return 0;
687 return meminfo.total - meminfo.free - meminfo.buffers - meminfo.cached; 705 return meminfo.total - meminfo.free - meminfo.buffers - meminfo.cached;
688 } 706 }
689 707
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 int score_len = static_cast<int>(score_str.length()); 858 int score_len = static_cast<int>(score_str.length());
841 return (score_len == file_util::WriteFile(oom_file, 859 return (score_len == file_util::WriteFile(oom_file,
842 score_str.c_str(), 860 score_str.c_str(),
843 score_len)); 861 score_len));
844 } 862 }
845 863
846 return false; 864 return false;
847 } 865 }
848 866
849 } // namespace base 867 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util.h ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698