fix(pool): 移除线程池预分配,优化大规模扫描内存占用

WithPreAlloc(true) 会预先创建所有 worker goroutine,
在大规模扫描(如 25域名×65535端口)时可能导致内存问题
This commit is contained in:
ZacharyZcR
2026-01-21 18:00:47 +08:00
parent 927bdbab92
commit 5e04ad97e7
+2 -1
View File
@@ -36,7 +36,8 @@ type AdaptivePool struct {
// NewAdaptivePool 创建自适应线程池
func NewAdaptivePool(size int, fn func(interface{}), state *common.State) (*AdaptivePool, error) {
pool, err := ants.NewPoolWithFunc(size, fn, ants.WithPreAlloc(true))
// 移除 WithPreAlloc(true),在大规模扫描时预分配可能导致内存问题
pool, err := ants.NewPoolWithFunc(size, fn)
if err != nil {
return nil, err
}