Утекает память в golang
Задумал я обкачать интернет. Сделал пару десятков тысяч воркеров. Скачал домены и запустил обход. Течёт память в воркере. Никак не могу найти.
func worker(timeout time.Duration, wg *sync.WaitGroup, in chan Pair, out chan Pair) {
client := &fasthttp.Client{
MaxIdleConnDuration: timeout,
}
for {
scheme := []string{"http", "https"}
domain := <-in
for _, s := range scheme {
time.Sleep(time.Second)
t := time.Now()
host := fmt.Sprintf("%s://%s", s, domain.String)
req := fasthttp.AcquireRequest()
defer fasthttp.ReleaseRequest(req)
req.Header.SetMethodBytes([]byte("GET"))
req.SetRequestURI(host)
resp := fasthttp.AcquireResponse()
defer fasthttp.ReleaseResponse(resp)
err := client.DoTimeout(req, resp, timeout)
s := fmt.Sprint(domain.Index, time.Now().Sub(t), resp.StatusCode(), err)
out <- Pair{String: s, Index: domain.Index}
}
}
wg.Done()
}