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

Unified Diff: build/android/pylib/android_commands.py

Issue 52833002: Purge unpinned ashmem before parsing /proc/$pid/smaps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove BuildTypeIsSet() Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/pylib/utils/host_path_finder.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 1741619276ce56042a9a3df6f3b004fed1ebe3ad..d81f20c8520022cd742ca41707f8c5ea01a25b47 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -21,6 +21,9 @@ import time
import cmd_helper
import constants
+
+from utils import host_path_finder
+
try:
from pylib import pexpect
except:
@@ -1409,6 +1412,19 @@ class AndroidCommands(object):
logging.warning('Could not find disk IO stats.')
return None
+ def _PurgeUnpinnedAshmem(self):
bulach 2013/11/05 16:25:14 probably best to make this public and let callers
Philippe 2013/11/05 16:37:42 Yeah, good idea. I don't think many clients will n
+ """Purges the unpinned ashmem memory for the whole system.
+
+ This can be used to make memory measurements more stable in particular.
+ """
+ host_path = host_path_finder.GetMostRecentHostPath('purge_ashmem')
+ if host_path:
+ device_path = os.path.join(constants.TEST_EXECUTABLE_DIR, 'purge_ashmem')
+ self.PushIfNeeded(host_path, device_path)
+ if self.RunShellCommand(device_path, log_result=True):
+ return
+ logging.error('Could not purge ashmem. Measurement might be unstable.')
+
def GetMemoryUsageForPid(self, pid):
"""Returns the memory usage for given pid.
@@ -1425,6 +1441,7 @@ class AndroidCommands(object):
"""
usage_dict = collections.defaultdict(int)
smaps = collections.defaultdict(dict)
+ self._PurgeUnpinnedAshmem()
current_smap = ''
for line in self.GetProtectedFileContents('/proc/%s/smaps' % pid,
log_result=False):
« no previous file with comments | « no previous file | build/android/pylib/utils/host_path_finder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698