mainClassName LinuxProcessSizeDetector set flag Reparse. set flag LeanMode. set flag l_withoutReflection. set flag NoAutoGunzip. do not include function get. sbool linux_rssFixedForZGC_verbose; public static long linux_rssFixedForZGC() throws IOException { ret linux_rssFixedForZGC(processID_int()); } public static long linux_rssFixedForZGC(int pid) throws IOException { //if (!is64BitLinux()) fail("Not on 64 Bit Linux"); S range = null; new TreeMap rssByRange; Pattern patAddr = Pattern.compile("^([0-9a-f]{1,16})-"); temp BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("/proc/" + pid + "/smaps"))); S s; while ((s = in.readLine()) != null) { Matcher m = patAddr.matcher(s); S addr = m.find() ? m.group(1) : null; if (addr != null) { //print("Have address: " + addr); S cleanedAddr = longToHex(parseUnsignedHexLong(addr) & ~((1L << 42)-1)); range = takeFirst_string(6, cleanedAddr); continue; } // else print("Not range: " + s); S[] p = parseColonProperty_array(s); if (eqic(first(p), "rss")) { long size = Long.parseLong(beforeSpace(p[1])); 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; }