jgilfelt / chuck

An in-app HTTP inspector for Android OkHttp clients
Apache License 2.0
4.68k stars 452 forks source link

OOM occurs while downloading or uploading large text file #57

Open konokol opened 6 years ago

konokol commented 6 years ago

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?

droidluv commented 6 years ago

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.