SagerNet / sing-box

The universal proxy platform
https://sing-box.sagernet.org/
Other
20.48k stars 2.44k forks source link

Possible Memory Leak #1736

Closed bigfei closed 3 months ago

bigfei commented 7 months ago

操作系统

Linux

系统版本

Linux arm64

安装类型

sing-box 原始命令行程序

如果您使用图形客户端程序,请提供该程序版本。

No response

版本

sing-box version 1.8.13

Environment: go1.22.2 linux/arm64
Tags: with_gvisor,with_quic,with_dhcp,with_wireguard,with_ech,with_utls,with_reality_server,with_acme,with_clash_api
Revision: 742adacce77f5cdb9eeb0efd67e7fbf44c966a12
CGO: disabled

描述

长时间运行后,发生OOM错误,被Docker自动重启。

重现方式

config.json :

{
  "log": {
    "disabled": true,
    "level": "trace",
    "timestamp": false
  },
  "inbounds": [
    {
      "type": "tun",
      "inet4_address": "172.19.0.1/30",
      "auto_route": false,
      "strict_route": false,
      "sniff": false,
      "endpoint_independent_nat": true,
      "stack": "mixed"
    }
  ],
  "outbounds": [
    {
      "tag": "proxy",
      "type": "selector",
      "outbounds": ["auto", "direct", "sing-box-reality", "sing-box-hysteria2", "sing-box-tuic"]
    },
    {
      "type": "vless",
      "tag": "sing-box-reality",
      "uuid": "xxx",
      "flow": "xtls-rprx-vision",
      "packet_encoding": "xudp",
      "network": "tcp",
      "server": "xxx",
      "server_port": xxx,
      "tls": {
        "enabled": true,
        "server_name": "xxx",
        "utls": {
          "enabled": true,
          "fingerprint": "chrome"
        },
        "reality": {
          "enabled": true,
          "public_key": "xxx",
          "short_id": "xxx"
        }
      }
    },
    {
      "type": "hysteria2",
      "server": "xxx",
      "server_port": xxx,
      "tag": "sing-box-hysteria2",
      "up_mbps": 200,
      "down_mbps": 1000,
      "password": "xxx",
      "tls": {
        "enabled": true,
        "server_name": "xxx",
        "insecure": false,
        "alpn": ["h3"]
      }
    },
    {
      "type": "tuic",
      "tag":"sing-box-tuic",
      "server": "xxx",
      "server_port": xxx,
      "uuid": "xxx",
      "password": "xxx",
      "congestion_control": "bbr",
      "udp_relay_mode": "quic",
      "tls": {
          "enabled": true,
          "server_name": "xxx",
          "insecure": false,
          "alpn": [ "h3" ]
      }
    },
    {
      "tag": "direct",
      "type": "direct"
    },
    {
      "tag": "block",
      "type": "block"
    },
    {
      "tag": "auto",
      "type": "urltest",
      "outbounds": ["sing-box-reality", "sing-box-hysteria2", "sing-box-tuic"],
      "url": "http://www.gstatic.com/generate_204",
      "interval": "1m",
      "tolerance": 50
    }
  ],
  "route": {
    "auto_detect_interface": true,
    "final": "proxy"
  },
  "experimental": {
    "debug": {
      "listen": ":9999"
    },
    "clash_api": {
      "external_controller": "0.0.0.0:9090",
      "external_ui_download_detour": "auto",
      "external_ui": "ui",
      "secret": "",
      "default_mode": "rule"
    }
  }
}

heapout svg: profile002

After removing the vless config, it seems the OOM is gone. Will try the solution mentioned in this issue #1607

日志

支持我们

完整性要求

siwee commented 6 months ago

我似乎也遇到类似的问题,我在VPS上运行sing-box 一段时间后会非常占用内存,严重的时候出现无法连接,需要重启sing-box程序才行,最多的一次观测到占用2G多内存,导致客户端无法连接服务器,重启后恢复。

sing-box版本: 1.8.12

image

nekohasekai commented 6 months ago

Try latest release

MaleicAcid commented 5 months ago

memory leak in both v1.10.0-alpha.18 and v1.9.3. The number of active connections and memory usage grow simultaneously as the following picture. This happens frequently after I add a vless forward proxy to a vless outbound using the detour attribute. I’m new to golang and singbox, what can I do to provide more information if I meet the same situation next time?

clashui top

github-actions[bot] commented 3 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days