Go语言内存优化GC调优与内存池1. GC调优import runtime/debug func init() { debug.SetGCPercent(100) }2. sync.Poolvar bufferPool sync.Pool{ New: func() interface{} { return make([]byte, 4096) }, } func getBuffer() []byte { return bufferPool.Get().([]byte) } func putBuffer(b []byte) { bufferPool.Put(b) }3. 总结合理的GC调优和内存池使用可以显著降低GC压力提高性能。