From 67fd816e3fdb17afdb0c6b8692f8dabb3ff1d68c Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sat, 28 Jul 2018 10:07:07 +0200 Subject: [PATCH] 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. --- cmd/eksterd/fetch.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/eksterd/fetch.go b/cmd/eksterd/fetch.go index ac05b9c..e8e38f5 100644 --- a/cmd/eksterd/fetch.go +++ b/cmd/eksterd/fetch.go @@ -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)