jgilfelt / chuck

An in-app HTTP inspector for Android OkHttp clients

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OOM occurs while downloading or uploading large text file

konokol opened this issue · comments

RequestBody and ResponseBody will be saved into database and later displayed on the Fragment if they are plain text. However, when uploading or downloading large text files, if Content-Type is text/* and serve responds with non-gzipped content, all the file content will be loaded into memory and saved into databse. In this situation, OOM occurs.

I don't think it is elegant to write all the plain text RequestBody or ResponseBody into database and memory ignoring content length. I add a threshold in ChuckInterceptor. When the content length is too large, we can write a String into database instead of all the content.

So, should I open a pull request?

This is definitely an issue, its not just with text files, when the http body is dealing with a large data files like uploading or downloading a video the OOM will happen.