set flag LeanMode. set flag l_withoutReflection. do not include function get. sbool linux_rssFixedForZGC_verbose; static long linux_rssFixedForZGC() { ret linux_rssFixedForZGC(processID_int()); } static long linux_rssFixedForZGC(int pid) { S text = loadTextFile("/proc/" + pid + "/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_string(6, cleanedAddr); continue; } // else print("Not range: " + s); PairS p = parseColonProperty(s); if (eqic(pairA(p), "rss")) { long size = Long.parseLong(beforeSpace(p.b)); if (size != 0) rssByRange.put(range, getOrCreate_long(rssByRange, range) + size); } } if (linux_rssFixedForZGC_verbose) for (Map.Entry e : rssByRange.entrySet()) { System.out.println("Address range " + rpad(e.getKey(), 16, 'x') + ": " + toK(e.getValue()) + " MB"); } Long min = null; for (S _range : ll("000004", "000008", "000010", "00007c")) { Long l = rssByRange.get(_range); if (l != null) min = min == null ? l : Math.min(min, l); } long total = 0; for (long l : rssByRange.values()) total += l; long guess = min == null ? total : total-min*3; ret guess*1024; }