Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential OOM issue when buffer? #14

Open
zmes50416 opened this issue May 26, 2022 · 4 comments
Open

Potential OOM issue when buffer? #14

zmes50416 opened this issue May 26, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@zmes50416
Copy link

I see this line still read entire body to buffer. so I think this will cause OutOfMemoryError if body is big enough. (not tested yet)
Can we change it to maxBodyLength? But I think this will bring another issue with gzip content.

@bartek-wesolowski
Copy link
Owner

Thank you for the suggestion. I'll think about changing this, although, in fact, it might cause more issues with compressed content and displaying correct content length.
If your responses contain hundreds of megabytes of data then you should probably not log them at all.

@bartek-wesolowski bartek-wesolowski added the enhancement New feature or request label May 31, 2022
@imcloud
Copy link

imcloud commented Aug 16, 2022

val buffer = Buffer()

requestBody.writeTo(buffer)

When uploading 1g files, the memory is full, and anr occurs.

Debugging found stuck in this line of code.

@bartek-wesolowski
Copy link
Owner

@imcloud ANRs don't occur because of full memory. They occur because of long running operations on the main thread. Are you sure you're not running your request on the main thread?

Your case seems to be very specific and I'm not sure if it would be the best idea to add this feature for everyone. It might be best for you to just copy the code of CustomizableHttpLoggingInterceptor (it's just one class) and customize it even more to skip logging some request bodies for specific requests or skip logging request bodies when they have a certain content type.

@imcloud
Copy link

imcloud commented Aug 22, 2022

Thank you for your reply.Yes, I have skiped logging when uploading a file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants