summaryrefslogtreecommitdiffstats
path: root/libmeminfo/tools/procmem.cpp
diff options
context:
space:
mode:
authorSandeep Patil <sspatil@google.com>2018-11-19 15:25:18 -0800
committerSandeep Patil <sspatil@google.com>2018-12-05 09:13:20 -0800
commitf12919935099acefa0b3e34e2ee36db85e2165b0 (patch)
treeefd897b484a319e8aca722e1de8e4a3406583804 /libmeminfo/tools/procmem.cpp
parent549feab6314690460e58f50e6084dfb95a1022e3 (diff)
downloadsystem_core-f12919935099acefa0b3e34e2ee36db85e2165b0.tar.gz
system_core-f12919935099acefa0b3e34e2ee36db85e2165b0.tar.bz2
system_core-f12919935099acefa0b3e34e2ee36db85e2165b0.zip
libmeminfo: Add support to reset workingset without procmeminfo objects
Bug: 114325007 Bug: 111694435 Test: libmeminfo_test 1 Change-Id: I816809cda13983e47294a956347a27085397cbcf Signed-off-by: Sandeep Patil <sspatil@google.com>
Diffstat (limited to 'libmeminfo/tools/procmem.cpp')
-rw-r--r--libmeminfo/tools/procmem.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/libmeminfo/tools/procmem.cpp b/libmeminfo/tools/procmem.cpp
index 3571e4173..d30c2f2ba 100644
--- a/libmeminfo/tools/procmem.cpp
+++ b/libmeminfo/tools/procmem.cpp
@@ -66,14 +66,12 @@ static void scan_usage(std::stringstream& ss, const MemUsage& usage, const std::
// clear string stream first.
ss.str("");
// TODO: use ::android::base::StringPrintf instead of <iomanip> here.
- if (!show_wss)
- ss << std::setw(6) << usage.vss/1024 << padding;
- ss << std::setw(6) << usage.rss/1024 << padding << std::setw(6)
- << usage.pss/1024 << padding << std::setw(6) << usage.uss/1024 << padding
- << std::setw(6) << usage.shared_clean/1024 << padding << std::setw(6)
- << usage.shared_dirty/1024 << padding << std::setw(6)
- << usage.private_clean/1024 << padding << std::setw(6)
- << usage.private_dirty/1024 << padding;
+ if (!show_wss) ss << std::setw(6) << usage.vss / 1024 << padding;
+ ss << std::setw(6) << usage.rss / 1024 << padding << std::setw(6) << usage.pss / 1024 << padding
+ << std::setw(6) << usage.uss / 1024 << padding << std::setw(6) << usage.shared_clean / 1024
+ << padding << std::setw(6) << usage.shared_dirty / 1024 << padding << std::setw(6)
+ << usage.private_clean / 1024 << padding << std::setw(6) << usage.private_dirty / 1024
+ << padding;
}
static int show(ProcMemInfo& proc, bool hide_zeroes, bool show_wss) {
@@ -158,14 +156,14 @@ int main(int argc, char* argv[]) {
}
bool need_wss = wss_reset || show_wss;
- ProcMemInfo proc(pid, need_wss);
if (wss_reset) {
- if (!proc.WssReset()) {
+ if (!ProcMemInfo::ResetWorkingSet(pid)) {
std::cerr << "Failed to reset working set of pid : " << pid << std::endl;
exit(EXIT_FAILURE);
}
return 0;
}
+ ProcMemInfo proc(pid, need_wss);
return show(proc, hide_zeroes, show_wss);
}