mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-22 19:21:52 +08:00
fix(pool): 移除线程池预分配,优化大规模扫描内存占用
WithPreAlloc(true) 会预先创建所有 worker goroutine, 在大规模扫描(如 25域名×65535端口)时可能导致内存问题
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user