getMapsCountLimit returns the maximum of memory map ares the process can allocate.
()
| 94 | |
| 95 | // getMapsCountLimit returns the maximum of memory map ares the process can allocate. |
| 96 | func (c *processCollector) getMapsCountLimit() (float64, error) { |
| 97 | file, err := os.Open(vmMapsLimitPath(c.procMountPoint)) |
| 98 | if err != nil { |
| 99 | return 0, err |
| 100 | } |
| 101 | defer file.Close() |
| 102 | |
| 103 | content, err := io.ReadAll(file) |
| 104 | if err != nil { |
| 105 | return 0, err |
| 106 | } |
| 107 | |
| 108 | content = bytes.TrimSpace(content) |
| 109 | |
| 110 | // A base value of zero makes ParseInt infer the correct base using the |
| 111 | // string's prefix, if any. |
| 112 | const base = 0 |
| 113 | value, err := strconv.ParseInt(string(content), base, 64) |
| 114 | if err != nil { |
| 115 | return 0, err |
| 116 | } |
| 117 | |
| 118 | return float64(value), nil |
| 119 | } |
| 120 | |
| 121 | func isSupported(procPath string) bool { |
| 122 | _, err := os.Stat(vmMapsLimitPath(procPath)) |
no test coverage detected