流媒体会话会在 glibc malloc arena 中留下大量不归还操作系统的冷匿名内存,实测单个 服务可累积到 2.5 GB 并占满整个 swap 文件(33 个 64/128 MB 匿名段,空闲时不增长, 随会话单调抬升)。本次从根因与兜底两侧处理: - systemd/maa-online-server.service: 设置 MALLOC_ARENA_MAX=2,把线程 arena 数量 从 8xCPU 压到 2,抑制 arena 膨胀 - systemd/maa-daily.service: 单元结束时经 ExecStopPost 重启 API 服务,回收当次会话残留 - systemd/maa-online-recycle.service, maa-online-recycle.timer: 新增每日 03:59(游戏 每日刷新前)独立回收定时器,错开更新与日常任务窗口,Persistent=false 避免补跑撞车 - bin/maa-online-can-recycle: 回收守卫,检测日常任务(systemd 单元或手工运行)是否 进行中,是则跳过回收,避免重启打断任务 - bin/maa-online-install-systemd: 安装并启用新增的回收单元 - README.md, user_config/README.md: 补充内存回收机制与定时器说明
23 lines
813 B
Desktop File
23 lines
813 B
Desktop File
[Unit]
|
|
Description=MAA Online cloud game API server
|
|
After=network-online.target
|
|
Wants=network-online.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
ExecStart=__ROOT__/bin/maa-online-server
|
|
Restart=always
|
|
RestartSec=5
|
|
# Belt and braces: never let a proxy environment leak into the cloud gaming
|
|
# server (bin/maa-online-server already unsets these).
|
|
Environment=NO_PROXY=localhost,127.0.0.1,::1
|
|
# Streaming sessions churn large temporaries (video frames, PNG buffers) across
|
|
# the asyncio/aiohttp/aiortc thread pool. glibc gives each thread its own 64 MB
|
|
# malloc arena and never returns it to the OS, so the service used to ratchet up
|
|
# to gigabytes of cold anonymous memory and eventually fill the swap file.
|
|
# Capping the arena count keeps the footprint flat.
|
|
Environment=MALLOC_ARENA_MAX=2
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|