github.com/igoogolx/clash@v1.19.8/common/pool/pool.go (about) 1 package pool 2 3 const ( 4 // io.Copy default buffer size is 32 KiB 5 // but the maximum packet size of vmess/shadowsocks is about 16 KiB 6 // so define a buffer of 20 KiB to reduce the memory of each TCP relay 7 RelayBufferSize = 20 * 1024 8 9 // RelayBufferSize uses 20KiB, but due to the allocator it will actually 10 // request 32Kib. Most UDPs are smaller than the MTU, and the TUN's MTU 11 // set to 9000, so the UDP Buffer size set to 16Kib 12 UDPBufferSize = 16 * 1024 13 ) 14 15 func Get(size int) []byte { 16 return defaultAllocator.Get(size) 17 } 18 19 func Put(buf []byte) error { 20 return defaultAllocator.Put(buf) 21 }