!7 p { int processID = nempty(args) ? parseInt(first(args)) : processID_int(); S text = loadTextFile("/proc/" + processID + "/smaps"); S range = null; new TreeMap 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 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"); }