-
-
Notifications
You must be signed in to change notification settings - Fork 464
Memory Optimization
This tun2socks project is designed for best performance, so the memory consumption might be relatively high sometimes.
However, starts with v2.4.0
, there are three tcp options added for tun2socks: tcp-sndbuf
, tcp-rcvbuf
, tcp-auto-tuning
.
-
tcp-sndbuf
: TCP send buffer size -
tcp-rcvbuf
: TCP receive buffer size -
tcp-auto-tuning
: TCP moderate receive buffer auto-tuning
The default value for send/receive buffer size is 212 KiB, and the receive buffer auto-tuning is disabled by default now (note that this option is enabled by default before v2.4.0
).
To optimize the memory usage in different systems, we can properly adjust the buffer size.
If you have enough memory resource available, you can set large buffer size, e.g., 1-4m
, and even turn on the tcp-auto-tuning
option. This operation will consume a lot RAM, but throughput would be increased.
In memory insufficient/sensitive system, it's recommended to set small buffer size, e.g., 16-64k
. Small buffer size can reduce memory usage and sometimes it can even less 80% RAM compared to large buffer size.