go-resty / resty

Simple HTTP and REST client library for Go
MIT License
9.68k stars 681 forks source link

memory leak when response is too large #751

Closed royalraul closed 4 months ago

royalraul commented 8 months ago
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.

john-behm-bertelsmann commented 7 months ago

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.

jeevatkm commented 4 months ago

@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