{"record":{"id":"c59efaefcfdbf194","repo":"glanceapp/glance","slug":"getting-memory-info-v","errorCode":null,"errorMessage":"getting memory info: %v","messagePattern":"getting memory info: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/sysinfo/sysinfo.go","lineNumber":188,"sourceCode":"\t\t\t} else {\n\t\t\t\tinfo.CPU.Load1Percent = uint8(math.Min((loadAvg.Load1/float64(coreCount))*100, 100))\n\t\t\t\tinfo.CPU.Load15Percent = uint8(math.Min((loadAvg.Load15/float64(coreCount))*100, 100))\n\t\t\t}\n\t\t} else {\n\t\t\taddErr(fmt.Errorf(\"getting load avg: %v\", err))\n\t\t}\n\t} else {\n\t\taddErr(fmt.Errorf(\"getting core count: %v\", err))\n\t}\n\n\tmemory, err := mem.VirtualMemory()\n\tif err == nil {\n\t\tinfo.Memory.IsAvailable = true\n\t\tinfo.Memory.TotalMB = memory.Total / 1024 / 1024\n\t\tinfo.Memory.UsedMB = memory.Used / 1024 / 1024\n\t\tinfo.Memory.UsedPercent = uint8(math.Min(memory.UsedPercent, 100))\n\t} else {\n\t\taddErr(fmt.Errorf(\"getting memory info: %v\", err))\n\t}\n\n\tswapMemory, err := mem.SwapMemory()\n\tif err == nil {\n\t\tinfo.Memory.SwapIsAvailable = true\n\t\tinfo.Memory.SwapTotalMB = swapMemory.Total / 1024 / 1024\n\t\tinfo.Memory.SwapUsedMB = swapMemory.Used / 1024 / 1024\n\t\tinfo.Memory.SwapUsedPercent = uint8(math.Min(swapMemory.UsedPercent, 100))\n\t} else {\n\t\taddErr(fmt.Errorf(\"getting swap memory info: %v\", err))\n\t}\n\n\t// currently disabled on Windows because it requires elevated privilidges, otherwise\n\t// keeps returning a single sensor with key \"ACPI\\\\ThermalZone\\\\TZ00_0\" which\n\t// doesn't seem to be the CPU sensor or correspond to anything useful when\n\t// compared against the temperatures Libre Hardware Monitor reports.\n\t// Also disabled on the bsd's because it's not implemented by go-psutil for them\n\tif runtime.GOOS != \"windows\" && runtime.GOOS != \"openbsd\" && runtime.GOOS != \"netbsd\" && runtime.GOOS != \"freebsd\" {","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/pkg/sysinfo/sysinfo.go#L170-L206","documentation":"Non-fatal: mem.VirtualMemory() failed, so TotalMB/UsedMB/UsedPercent stay unset and the memory section of server-stats shows as unavailable; recorded via addErr and collection continues (swap is attempted separately).","triggerScenarios":"Reading memory stats fails: /proc/meminfo missing or unreadable on Linux, hoststats API denied on macOS, or WMI/perf-counter failure on Windows.","commonSituations":"Containers with /proc masked or not mounted; minimal base images; systems where the gopsutil backend syscall is denied by seccomp.","solutions":["Confirm /proc/meminfo is mounted and readable from the Glance process","Adjust container security options (seccomp/apparmor) or mounts that block /proc","If memory stats are simply unavailable in the environment, suppress the memory panel rather than chasing the error"],"exampleFix":"# docker run\n# before\ndocker run -v ./glance.yml:/app/config/glance.yml glance\n\n# after (ensure proc is available)\ndocker run -v ./glance.yml:/app/config/glance.yml --pid=host glance","handlingStrategy":"fallback","validationCode":null,"typeGuard":"func isMemoryErr(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"getting memory info\")\n}","tryCatchPattern":"info, err := sysinfo.Get()\nif isMemoryErr(err) {\n    // hide the memory panel; other stats remain valid\n    renderServerStats(info, hideMemory=true)\n}","preventionTips":["Mount /proc (meminfo) in containers and avoid masking it with security options","Render panels conditionally on info.Memory.IsAvailable so partial failures degrade silently"],"tags":["sysinfo","memory","container","proc"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}