From 5e04ad97e792ac1c852acd81a2ef22ef29d11800 Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Wed, 21 Jan 2026 18:00:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(pool):=20=E7=A7=BB=E9=99=A4=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E6=B1=A0=E9=A2=84=E5=88=86=E9=85=8D=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=A4=A7=E8=A7=84=E6=A8=A1=E6=89=AB=E6=8F=8F=E5=86=85?= =?UTF-8?q?=E5=AD=98=E5=8D=A0=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WithPreAlloc(true) 会预先创建所有 worker goroutine, 在大规模扫描(如 25域名×65535端口)时可能导致内存问题 --- core/adaptive_pool.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/adaptive_pool.go b/core/adaptive_pool.go index bafaa68..e504973 100644 --- a/core/adaptive_pool.go +++ b/core/adaptive_pool.go @@ -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 }