Fix memory leak

Close resp.Body in the main Fetch function. When the resp.Body is not
closed, it will keep all HTTP responses in memory and that amount will
grow, quite fast.
This commit is contained in:
Peter Stuifzand 2018-07-28 10:07:07 +02:00
parent e79b883faa
commit 67fd816e3f

View File

@ -510,6 +510,7 @@ func Fetch2(fetchURL string) (*http.Response, error) {
if err != nil {
return nil, fmt.Errorf("error while fetching %s: %s", u, err)
}
defer resp.Body.Close()
var b bytes.Buffer
resp.Write(&b)