系统参数抽离

This commit is contained in:
hahwu 2026-03-24 14:10:03 +08:00
parent 2aa7947dad
commit 36d0eed502
2 changed files with 9 additions and 2 deletions

View File

@ -0,0 +1,6 @@
package MergeConst
const (
Go_gc_percent = 200
Go_gc_memory_limit = 1024 << 20
)

View File

@ -6,6 +6,7 @@ import (
_ "net/http/pprof"
"runtime"
"runtime/debug"
"server/MergeConst"
"server/conf"
"server/game"
"server/gate"
@ -27,8 +28,8 @@ func main() {
lconf.CenterAddr = conf.Server.CenterAddr
lconf.PendingWriteNum = conf.PendingWriteNum
// 当内存>256M时开始GC
debug.SetGCPercent(200)
debug.SetMemoryLimit(1024 << 20)
debug.SetGCPercent(MergeConst.Go_gc_percent)
debug.SetMemoryLimit(MergeConst.Go_gc_memory_limit)
// 启动 pprof仅绑定本地
go func() {
// 如果需要绑定所有接口改为 ":6060"