2019-04-23 15:29:36 +00:00
|
|
|
package pool
|
|
|
|
|
|
|
|
const (
|
|
|
|
// io.Copy default buffer size is 32 KiB
|
|
|
|
// but the maximum packet size of vmess/shadowsocks is about 16 KiB
|
|
|
|
// so define a buffer of 20 KiB to reduce the memory of each TCP relay
|
2020-04-24 16:30:40 +00:00
|
|
|
RelayBufferSize = 20 * 1024
|
2021-11-03 14:26:51 +00:00
|
|
|
|
|
|
|
// RelayBufferSize uses 20KiB, but due to the allocator it will actually
|
|
|
|
// request 32Kib. Most UDPs are smaller than the MTU, and the TUN's MTU
|
|
|
|
// set to 9000, so the UDP Buffer size set to 16Kib
|
|
|
|
UDPBufferSize = 16 * 1024
|
2019-04-23 15:29:36 +00:00
|
|
|
)
|
|
|
|
|
2020-04-24 16:30:40 +00:00
|
|
|
func Get(size int) []byte {
|
2022-10-06 11:23:38 +00:00
|
|
|
return defaultAllocator.Get(size)
|
2020-04-24 16:30:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Put(buf []byte) error {
|
2022-10-06 11:23:38 +00:00
|
|
|
return defaultAllocator.Put(buf)
|
2020-04-24 16:30:40 +00:00
|
|
|
}
|