MCPcopy Create free account
hub / github.com/containerd/nerdctl / getHostMemLimit

Function getHostMemLimit

pkg/statsutil/stats_linux.go:94–115  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92}
93
94func getHostMemLimit() float64 {
95 file, err := os.Open("/proc/meminfo")
96 if err != nil {
97 return float64(^uint64(0))
98 }
99 defer file.Close()
100
101 scanner := bufio.NewScanner(file)
102 for scanner.Scan() {
103 if strings.HasPrefix(scanner.Text(), "MemTotal:") {
104 fields := strings.Fields(scanner.Text())
105 if len(fields) >= 2 {
106 memKb, err := strconv.ParseUint(fields[1], 10, 64)
107 if err == nil {
108 return float64(memKb * 1024) // kB to bytes
109 }
110 }
111 break
112 }
113 }
114 return float64(^uint64(0))
115}
116
117func calculateCgroupCPUPercent(previousStats *ContainerStats, metrics *v1.Metrics, systemInfo SystemInfo) float64 {
118 var (

Callers 1

getCgroupMemLimitFunction · 0.85

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…