admin管理员组文章数量:1310108
I am working with OkHttp for my connections. To avoid memory leaks by closing responses. But the docs and none of the information I found explains which close to use.
Here are the difference close functions I've found
response.close()
response.body.close()
response.peekBody(Int).close()
response.cacheResponse.close()
responseworkResponse.close()
and there's probably more. But it seems like the big one is response.close()
which is fundamentally different from the others. Do I need to close the whole thing or just the body to avoid memory leaks?
I am working with OkHttp for my connections. To avoid memory leaks by closing responses. But the docs and none of the information I found explains which close to use.
Here are the difference close functions I've found
response.close()
response.body.close()
response.peekBody(Int).close()
response.cacheResponse.close()
responseworkResponse.close()
and there's probably more. But it seems like the big one is response.close()
which is fundamentally different from the others. Do I need to close the whole thing or just the body to avoid memory leaks?
1 Answer
Reset to default 0From the Response docs:
This class implements Closeable. Closing it simply closes its response body. See ResponseBody for an explanation and examples.
本文标签: In OkHttp what is the difference between responseclose() and responsebodyclose()Stack Overflow
版权声明:本文标题:In OkHttp what is the difference between response.close() and response.body.close()? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741855102a2401296.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论