memory usage through "json.NewDecoder(res.Body).Decode(&gr)"

97 views
Skip to first unread message

RS

unread,
Oct 26, 2021, 10:25:28 AM10/26/21
to golang-nuts
err = json.NewDecoder(res.Body).Decode(&gr)
if err != nil {
log.Println("ERROR:", err)
return
}

Using json.newdecoder to decode the coming response body from client? 
Here is also the issue of " loading the entire response in memory and parsing it" is a matter?
As I am not using a buffer to copy?

Thanks

Amnon

unread,
Oct 26, 2021, 1:30:09 PM10/26/21
to golang-nuts
Sadly Decode does collect up the entire res.Body into memory.
See https://github.com/golang/go/issues/33714
Reply all
Reply to author
Forward
0 new messages