MCPcopy Create free account
hub / github.com/cortexproject/cortex / getMapsCountLimit

Method getMapsCountLimit

pkg/util/process/collector.go:96–119  ·  view source on GitHub ↗

getMapsCountLimit returns the maximum of memory map ares the process can allocate.

()

Source from the content-addressed store, hash-verified

94
95// getMapsCountLimit returns the maximum of memory map ares the process can allocate.
96func (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
121func isSupported(procPath string) bool {
122 _, err := os.Stat(vmMapsLimitPath(procPath))

Callers 1

CollectMethod · 0.95

Calls 2

vmMapsLimitPathFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected