SagerNet / SagerNet/sing-box

[sfm] memory increases constantly whenever you restart sfm immediately(same config)

Open
#4,276 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
38.1k
Forks
4.6k
Avg merge
19d 15h
Merged PRs (30d)
1

Description

Operating system

macOS

System version

macos27

Installation type

sing-box for macOS Graphical Client

If you are using a graphical client, please provide the version of the client.

1.14.beta39

Version

Description

memory increases constantly whenever you restart sfm(same config).

Image Image Image
Reproduction

restart sfm

{
  "log": {
    "level": "warn",
    "output": "sing-box.log",
    "timestamp": true
  },
  "dns": {
    "servers": [
      {
        "type": "https",
        "tag": "dns_proxy",
        "detour": "proxy",
        "server": "8.8.8.8"
      },
      {
        "type": "hosts",
        "tag": "hosts"
      },
      {
        "type": "local",
        "tag": "local"
      },
      {
        "type": "quic",
        "tag": "dns_direct",
        "server": "223.5.5.5"
      },
      {
        "type": "fakeip",
        "tag": "fakeip",
        "inet4_range": "198.18.0.0/15",
        "inet6_range": "fc00::/18"
      }
    ],
    "rules": [
      {
        "preferred_by": "hosts",
        "server": "hosts"
      },
      {
        "clash_mode": "Direct",
        "server": "local"
      },
      {
        "clash_mode": "Global",
        "server": "fakeip"
      },
      {
        "type": "logical",
        "mode": "and",
        "rules": [
          {
            "clash_mode": "AllowAds",
            "invert": true
          },
          {
            "rule_set": "ads"
          }
        ],
        "action": "predefined"
      },
      {
        "domain_suffix": [".local", ".lan", "miwifi.com"],
        "rule_set": ["private", "bilibili_domain", "apple_cn"],
        "server": "local"
      },
      {
        "process_name": [
          "Microsoft Outlook",
          "motrix-next-engine",
          "aria2c.exe",
          "fdm.exe",
          "folx.exe",
          "nettransport.exe",
          "thunder.exe",
          "transmission.exe",
          "utorrent.exe",
          "webtorrent.exe",
          "webtorrent helper.exe",
          "qbittorrent.exe",
          "downloadservice.exe",
          "weiyun.exe",
          "baidunetdisk.exe"
        ],
        "server": "local"
      },
      {
        "domain": ["ghfast.top", "cdn.jsdelivr.net"],
        "domain_suffix": [
          "tplogin.cn",
          "router.asus.com",
          "tendawifi.com",
          "tplinkwifi.net",
          "app-measurement.com",
          "hm.baidu.com",
          "firebaselogging.googleapis.com",
          "firebaselogging-pa.googleapis.com",
          "beacons.gvt2.com",
          "beacons2.gvt2.com",
          "beacons3.gvt2.com",
          "tracking.miui.com",
          "market.xiaomi.com",
          "lancache.steamcontent.com"
        ],
        "rule_set": ["cn_domain", "microsoft@cn"],
        "server": "dns_direct"
      },
      {
        "query_type": ["A", "AAAA"],
        "rule_set": "proxy_domain",
        "server": "fakeip"
      },
      {
        "rule_set": "proxy_domain",
        "invert": true,
        "action": "evaluate",
        "server": "dns_proxy",
        "client_subnet": "114.114.114.114/24"
      },
      {
        "rule_set": "cn_ip",
        "match_response": true,
        "server": "local"
      },
      {
        "query_type": ["A", "AAAA"],
        "server": "fakeip"
      }
    ],
    "final": "dns_proxy",
    "optimistic": true
  },
  "ntp": {
    "enabled": true,
    "interval": "30m0s",
    "server": "ntp.aliyun.com",
    "server_port": 123
  },
  "http_clients": [
    {
      "tag": "proxy_client",
      "version": 2,
      "headers": {
        "Authorization": ""
      },
      "detour": "proxy",
      "stream_receive_window": 0,
      "connection_receive_window": 0
    }
  ],
  "inbounds": [
    {
      "type": "tun",
      "address": ["172.18.0.1/30", "fdfe:dcba:9876::1/126"],
      "auto_route": true,
      "loopback_address": "10.7.0.1",
      "stack": "mixed",
      "platform": {
        "http_proxy": {
          "enabled": true,
          "server": "127.0.0.1",
          "server_port": 7890
        }
      }
    },
    {
      "type": "mixed",
      "listen": "127.0.0.1",
      "listen_port": 7890
    }
  ],
  "outbounds": [
    {
      "type": "selector",
      "tag": "proxy",
      "outbounds": [
        "hk-auto",
        "tw-auto",
        "jp-auto",
        "sg-auto",
        "us-auto",
        "noCN-auto",
        "all"
      ],
      "default": "noCN-auto"
    },
    {
      "type": "selector",
      "tag": "ai",
      "outbounds": [
        "proxy",
        "direct",
        "hk-auto",
        "tw-auto",
        "jp-auto",
        "sg-auto",
        "us-auto",
        "noCN-auto",
        "all"
      ],
      "default": "us-auto"
    },
    {
      "type": "selector",
      "tag": "telegram",
      "outbounds": [
        "proxy",
        "direct",
        "hk-auto",
        "tw-auto",
        "jp-auto",
        "sg-auto",
        "us-auto",
        "all"
      ]
    },
    {
      "type": "selector",
      "tag": "emby",
      "outbounds": [
        "proxy",
        "direct",
        "hk-auto",
        "tw-auto",
        "jp-auto",
        "sg-auto",
        "us-auto",
        "all"
      ]
    },
    {
      "type": "selector",
      "tag": "google",
      "outbounds": [
        "proxy",
        "direct",
        "hk-auto",
        "tw-auto",
        "jp-auto",
        "sg-auto",
        "us-auto",
        "noCN-auto",
        "all"
      ]
    },
    {
      "type": "selector",
      "tag": "streaming",
      "outbounds": [
        "proxy",
        "direct",
        "hk-auto",
        "tw-auto",
        "jp-auto",
        "sg-auto",
        "us-auto",
        "all"
      ],
      "default": "direct"
    },
    {
      "type": "selector",
      "tag": "github",
      "outbounds": [
        "proxy",
        "direct",
        "hk-auto",
        "tw-auto",
        "jp-auto",
        "sg-auto",
        "us-auto",
        "all"
      ],
      "default": "us-auto"
    },
    {
      "type": "selector",
      "tag": "microsoft@cn",
      "outbounds": [
        "proxy",
        "direct",
        "hk-auto",
        "tw-auto",
        "jp-auto",
        "sg-auto",
        "us-auto",
        "all"
      ],
      "default": "direct"
    },
    {
      "type": "selector",
      "tag": "bilibili",
      "outbounds": [
        "proxy",
        "direct",
        "hk-auto",
        "tw-auto",
        "jp-auto",
        "sg-auto",
        "us-auto",
        "all"
      ],
      "default": "direct"
    },
    {
      "type": "selector",
      "tag": "cn",
      "outbounds": [
        "proxy",
        "direct",
        "hk-auto",
        "tw-auto",
        "jp-auto",
        "sg-auto",
        "us-auto",
        "all"
      ],
      "default": "direct"
    },
    {
      "type": "direct",
      "tag": "direct"
    },
    {
      "type": "urltest",
      "tag": "noCN-auto",
      "outbounds": [],
      "interval": "2m0s",
      "interrupt_exist_connections": true
    },
    {
      "type": "urltest",
      "tag": "hk-auto",
      "outbounds": [],
      "interval": "2m0s",
      "interrupt_exist_connections": true
    },
    {
      "type": "urltest",
      "tag": "tw-auto",
      "outbounds": [],
      "interval": "2m0s",
      "interrupt_exist_connections": true
    },
    {
      "type": "urltest",
      "tag": "jp-auto",
      "outbounds": [],
      "interval": "2m0s",
      "interrupt_exist_connections": true
    },
    {
      "type": "urltest",
      "tag": "sg-auto",
      "outbounds": [],
      "interval": "2m0s",
      "interrupt_exist_connections": true
    },
    {
      "type": "urltest",
      "tag": "us-auto",
      "outbounds": [],
      "interval": "2m0s",
      "interrupt_exist_connections": true
    },
    {
      "type": "selector",
      "tag": "all",
      "outbounds": []
    }
  ],
  "route": {
    "rules": [
      {
        "ip_is_private": true,
        "outbound": "direct"
      },
      {
        "clash_mode": "Global",
        "outbound": "all"
      },
      {
        "clash_mode": "Direct",
        "outbound": "direct"
      },
      {
        "process_name": [
          "Microsoft Outlook",
          "motrix-next-engine",
          "aria2c.exe",
          "fdm.exe",
          "folx.exe",
          "nettransport.exe",
          "thunder.exe",
          "transmission.exe",
          "utorrent.exe",
          "webtorrent.exe",
          "webtorrent helper.exe",
          "qbittorrent.exe",
          "downloadservice.exe",
          "weiyun.exe",
          "baidunetdisk.exe"
        ],
        "outbound": "direct"
      },
      {
        "rule_set": "telegram_ip",
        "outbound": "telegram"
      },
      {
        "rule_set": "cn_ip",
        "outbound": "cn"
      },
      {
        "action": "sniff"
      },
      {
        "type": "logical",
        "mode": "and",
        "rules": [
          {
            "protocol": "stun"
          },
          {
            "rule_set": "cn_ip",
            "invert": true
          }
        ],
        "action": "reject"
      },
      {
        "type": "logical",
        "mode": "and",
        "rules": [
          {
            "clash_mode": "AllowAds",
            "invert": true
          },
          {
            "rule_set": "ads"
          }
        ],
        "action": "reject"
      },
      {
        "rule_set": "ai_domain",
        "outbound": "ai"
      },
      {
        "rule_set": "telegram_domain",
        "outbound": "telegram"
      },
      {
        "rule_set": ["youtube_domain", "netflix_domain"],
        "outbound": "streaming"
      },
      {
        "rule_set": ["google_domain", "google_ip"],
        "outbound": "google"
      },
      {
        "domain_keyword": "emby.",
        "rule_set": "emby",
        "outbound": "emby"
      },
      {
        "rule_set": "github",
        "outbound": "github"
      },
      {
        "rule_set": "microsoft@cn",
        "outbound": "microsoft@cn"
      },
      {
        "rule_set": "bilibili_domain",
        "outbound": "bilibili"
      },
      {
        "domain": "captive.apple.com",
        "domain_suffix": "wiwide.com",
        "outbound": "direct"
      },
      {
        "domain": "apps.apple.com",
        "outbound": "proxy"
      },
      {
        "domain_suffix": "miwifi.com",
        "rule_set": ["cn_domain", "apple_cn"],
        "outbound": "cn"
      }
    ],
    "rule_set": [
      {
        "type": "remote",
        "tag": "microsoft@cn",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/microsoft@cn.srs"
      },
      {
        "type": "remote",
        "tag": "apple_cn",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/apple-cn.srs"
      },
      {
        "type": "remote",
        "tag": "bilibili_domain",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo-lite/geosite/bilibili.srs"
      },
      {
        "type": "remote",
        "tag": "cn_ip",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geoip/cn.srs"
      },
      {
        "type": "remote",
        "tag": "cn_domain",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo-lite/geosite/cn.srs"
      },
      {
        "type": "remote",
        "tag": "google_domain",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo-lite/geosite/google.srs"
      },
      {
        "type": "remote",
        "tag": "google_ip",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo-lite/geoip/google.srs"
      },
      {
        "type": "remote",
        "tag": "netflix_domain",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo-lite/geosite/netflix.srs"
      },
      {
        "type": "remote",
        "tag": "ai_domain",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/category-ai-chat-!cn.srs"
      },
      {
        "type": "remote",
        "tag": "proxy_domain",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/geolocation-!cn.srs"
      },
      {
        "type": "remote",
        "tag": "telegram_ip",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo-lite/geoip/telegram.srs"
      },
      {
        "type": "remote",
        "tag": "telegram_domain",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo-lite/geosite/telegram.srs"
      },
      {
        "type": "remote",
        "tag": "youtube_domain",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo-lite/geosite/youtube.srs"
      },
      {
        "type": "remote",
        "tag": "ads",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/category-ads@ads.srs"
      },
      {
        "type": "remote",
        "tag": "private",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/private.srs"
      },
      {
        "type": "remote",
        "tag": "github",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/github.srs"
      },
      {
        "type": "remote",
        "tag": "emby",
        "url": "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/category-emby.srs"
      }
    ],
    "final": "proxy",
    "auto_detect_interface": true,
    "default_domain_resolver": "dns_direct",
    "default_http_client": "proxy_client"
  },
  "experimental": {
    "cache_file": {
      "enabled": true,
      "store_fakeip": true
    },
    "clash_api": {
      "external_controller": "127.0.0.1:9090",
      "external_ui": "ClashUIforSingbox",
      "external_ui_download_url": "https://github.com/Zephyruso/zashboard/releases/latest/download/dist-no-fonts.zip"
    }
  }
}
Logs

Supporter
Integrity requirements
  • I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
  • I confirm that I have provided the server and client configuration files and process that can be reproduced locally, instead of a complicated client configuration file that has been stripped of sensitive data.
  • I confirm that I have provided the simplest configuration that can be used to reproduce the error I reported, instead of depending on remote servers, TUN, graphical interface clients, or other closed-source software.
  • I confirm that I have provided the complete configuration files and logs, rather than just providing parts I think are useful out of confidence in my own intelligence.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the report in the macOS graphical client with the supplied configuration, restarting sfm repeatedly while observing memory usage. Trace the sfm restart entry point to identify what remains allocated between identical runs; done means repeated restarts no longer cause memory to increase continuously.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, macos
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.