Download Jar. Libraryless. Click here for Pure Java version (3311L/21K).
!7 p { int processID = nempty(args) ? parseInt(first(args)) : processID_int(); S text = loadTextFile("/proc/" + processID + "/smaps"); S range = null; new TreeMap<S, Long> rssByRange; for (S s : lines(text)) { S addr = regexpFirstGroupIC("^([0-9a-f]{1,16})-", s); if (addr != null) { addr = lpad(addr, 16, '0'); //print("Have address: " + addr); S cleanedAddr = longToHex(parseUnsignedHexLong(addr) & ~((1L << 42)-1)); //range = takeFirst(/*7*/6, addr); range = takeFirst(6, cleanedAddr); continue; } // else print("Not range: " + s); S[] p = parseColonProperty_array(s); if (eqic(first(p), "rss")) { long size = parseFirstLong(p[1]); if (size != 0) rssByRange.put(range, getOrCreate_long(rssByRange, range) + size); } } //pnl(rssByRange); for (unpair S _range, long size : mapToPairs(rssByRange)) { print("Address range " + rpad(_range, 16, 'x') + ": " + toK(size) + " MB"); } L<Long> offendingRanges = ll( toLong(rssByRange.get("000004")), toLong(rssByRange.get("000008")), toLong(rssByRange.get("000010")), toLong(rssByRange.get("00007c"))); long total = longSum(values(rssByRange)); long guess = total-longMin(offendingRanges)*3; print("Pessimisticly guessed process size: " + toK(guess) + " MB"); }
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, whxojlpjdney
No comments. add comment
Snippet ID: | #1025540 |
Snippet name: | Parse /proc/.../smaps Spike |
Eternal ID of this version: | #1025540/38 |
Text MD5: | 9fa45b5f997202a03ee74418088e86f4 |
Transpilation MD5: | 7bcd7d151c473e280fdb73a4e6bd035f |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-10-03 13:14:26 |
Source code size: | 1374 bytes / 39 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 380 / 1266 |
Version history: | 37 change(s) |
Referenced in: | #1025541 - linux_rawRSSTotalFromSMAPS |