Memory Optimization
If your device has limited RAM, Tailscale may consume excessive memory or get killed by the OOM Killer. You can reduce memory usage by adjusting the GOGC parameter.
Symptoms
You might need this optimization if:
- Your device has limited RAM and Tailscale consumes too much memory
- Tailscale is killed and restarted by the OOM Killer
- Tailscale keeps restarting unexpectedly
Solution: Adjust GOGC
- Edit the init script:
sh
vi /etc/init.d/tailscale- Find this line:
sh
procd_set_param env TS_DEBUG_FIREWALL_MODE="$fw_mode"- Append
GOGC=10to the end of that line:
sh
procd_set_param env TS_DEBUG_FIREWALL_MODE="$fw_mode" GOGC=10- Restart Tailscale:
sh
/etc/init.d/tailscale restartHow It Works
GOGC=10tells the Go runtime to trigger GC when heap grows by 10% (default is 100%)- More frequent but smaller GC cycles
- Trade-off: Higher CPU usage, lower peak memory
- Suitable for devices with limited RAM (128MB or less)
WARNING
Setting GOGC too low (< 5) may cause performance degradation. Start with 10 and adjust as needed.