resty icon indicating copy to clipboard operation
resty copied to clipboard

memory leak when response is too large

Open royalraul opened this issue 2 years ago • 1 comments

image using go-resty, where response body is too large, the memory usage is increasing gradually, I find 'if response.body, err = io.ReadAll(body); err != nil' may be the cause. could it be changed using ‘io.copy’ or other way.

royalraul avatar Nov 15 '23 03:11 royalraul

You can disable response parsing/reading and use io.Copy manually with the raw response object's body. Don't forget to close the response object's body. Issue can be closed.

john-behm-bertelsmann avatar Dec 05 '23 11:12 john-behm-bertelsmann

@john-behm-bertelsmann Thanks for your response.

@royalraul For the large response body size, it is recommended to take control on your end, since its not a typical JSON or XML or Text. https://pkg.go.dev/github.com/go-resty/resty/v2#Request.SetDoNotParseResponse

jeevatkm avatar Mar 02 '24 20:03 jeevatkm