跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

memory_linux.go

29 行 · 495 B历史下载
1package host
2
3import (
4 "os"
5 "strconv"
6 "strings"
7)
8
9func MemoryPressure() bool {
10 data, err := os.ReadFile("/proc/meminfo")
11 if err != nil {
12 return false
13 }
14 var total, available uint64
15 for _, line := range strings.Split(string(data), "\n") {
16 f := strings.Fields(line)
17 if len(f) < 2 {
18 continue
19 }
20 v, _ := strconv.ParseUint(f[1], 10, 64)
21 if f[0] == "MemTotal:" {
22 total = v
23 }
24 if f[0] == "MemAvailable:" {
25 available = v
26 }
27 }
28 return total > 0 && available < total/10
29}