Skip to content

Question: Do I need to close ResponseBody? #2950

Open
@Malachiasz

Description

@Malachiasz

When Retrofit2 returns okhttp3.ResponseBody then it has to be closed in order to avoid memory leaks, right? It's something what I have just noticed in our code and am not sure.

@GET("accountId")
@WorkerThread
Call<ResponseBody> getUserData(@Header(NetworkConstants.Header.AUTHORIZATION) String accessToken);

...
Response<ResponseBody> response = interface.getUserData();
// do something with response
response.body().close()

https://stackoverflow.com/questions/53265862/do-i-need-to-close-response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions