Libraryless. Click here for Pure Java version (450L/3K).
1 | mainClassName LinuxProcessSizeDetector |
2 | |
3 | set flag Reparse. |
4 | set flag LeanMode. |
5 | set flag l_withoutReflection. |
6 | set flag NoAutoGunzip. |
7 | do not include function get. |
8 | |
9 | sbool linux_rssFixedForZGC_verbose; |
10 | |
11 | public static long linux_rssFixedForZGC() throws IOException {
|
12 | ret linux_rssFixedForZGC(processID_int()); |
13 | } |
14 | |
15 | public static long linux_rssFixedForZGC(int pid) throws IOException {
|
16 | //if (!is64BitLinux()) fail("Not on 64 Bit Linux");
|
17 | |
18 | S range = null; |
19 | new TreeMap<S, Long> rssByRange; |
20 | Pattern patAddr = Pattern.compile("^([0-9a-f]{1,16})-");
|
21 | temp BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("/proc/" + pid + "/smaps")));
|
22 | S s; |
23 | while ((s = in.readLine()) != null) {
|
24 | Matcher m = patAddr.matcher(s); |
25 | S addr = m.find() ? m.group(1) : null; |
26 | if (addr != null) {
|
27 | //print("Have address: " + addr);
|
28 | S cleanedAddr = longToHex(parseUnsignedHexLong(addr) & ~((1L << 42)-1)); |
29 | range = takeFirst_string(6, cleanedAddr); |
30 | continue; |
31 | } // else print("Not range: " + s);
|
32 | S[] p = parseColonProperty_array(s); |
33 | if (eqic(first(p), "rss")) {
|
34 | long size = Long.parseLong(beforeSpace(p[1])); |
35 | if (size != 0) |
36 | rssByRange.put(range, getOrCreate_long(rssByRange, range) + size); |
37 | } |
38 | } |
39 | if (linux_rssFixedForZGC_verbose) |
40 | for (Map.Entry<S, Long> e : rssByRange.entrySet()) {
|
41 | System.out.println("Address range " + rpad(e.getKey(), 16, 'x') + ": " + toK(e.getValue()) + " MB");
|
42 | } |
43 | |
44 | Long min = null; |
45 | for (S _range : ll("000004", "000008", "000010", "00007c")) {
|
46 | Long l = rssByRange.get(_range); |
47 | if (l != null) min = min == null ? l : Math.min(min, l); |
48 | } |
49 | |
50 | long total = 0; |
51 | for (long l : rssByRange.values()) total += l; |
52 | long guess = min == null ? total : total-min*3; |
53 | ret guess*1024; |
54 | } |
Began life as a copy of #1025548
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1025551 |
| Snippet name: | linux_rssFixedForZGC for export |
| Eternal ID of this version: | #1025551/23 |
| Text MD5: | be16b57fdf9236cbb47ddffe915b7a50 |
| Transpilation MD5: | 13ee2262983ef7eee2d2c35183df5562 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-10-03 13:31:19 |
| Source code size: | 1857 bytes / 54 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 486 / 775 |
| Version history: | 22 change(s) |
| Referenced in: | [show references] |