移除-bl参数。buf尺寸过小的话,反倒会导致更大的内存泄漏问题

This commit is contained in:
hahahrfool
2022-03-31 09:59:48 +08:00
parent 7df432ea7f
commit 2f53ffe591
2 changed files with 1 additions and 16 deletions

View File

@@ -112,8 +112,6 @@ func main() {
defer p.Stop()
}
utils.AdjustBufSize()
ll_beforeLoadConfigFile := utils.LogLevel
usereadv_beforeLoadConfigFile := netLayer.UseReadv

View File

@@ -2,7 +2,6 @@ package utils
import (
"bytes"
"flag"
"sync"
)
@@ -25,12 +24,9 @@ const StandardBytesLength int = 1500
// https://en.wikipedia.org/wiki/Maximum_transmission_unit
//本作设定的最大buf大小64k
var MaxBufLen = DefaultMaxBufLen
const DefaultMaxBufLen = 64 * 1024
const MaxBufLen = 64 * 1024
func init() {
flag.IntVar(&MaxBufLen, "bl", DefaultMaxBufLen, "buf len")
standardBytesPool = sync.Pool{
New: func() interface{} {
@@ -51,15 +47,6 @@ func init() {
}
}
//给了参数调节buf大小后,需要更新pool
func AdjustBufSize() {
standardPacketPool = sync.Pool{
New: func() interface{} {
return make([]byte, MaxBufLen)
},
}
}
//从Pool中获取一个 *bytes.Buffer
func GetBuf() *bytes.Buffer {
return bufPool.Get().(*bytes.Buffer)