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

OutOfMemoryError with logging enabled #82

Closed
wonderfly opened this issue Jan 9, 2015 · 5 comments
Closed

OutOfMemoryError with logging enabled #82

wonderfly opened this issue Jan 9, 2015 · 5 comments
Assignees
Labels
priority: p0 Highest priority. Critical issue. P0 implies highest priority. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@wonderfly
Copy link
Contributor

From yan...@google.com on April 07, 2012 05:42:31

Version of google-http-java-client (e.g. 1.5.0-beta)? 1.8.0-beta Java environment (e.g. Java 6, Android 2.3, App Engine)? Android Describe the problem. Reported by user here: http://stackoverflow.com/questions/9941378/how-to-download-a-large-file-using-google-api-java-client-on-android copied here:

Recently, I try to use google-api-java-client library to access google document. I can use this library to get a list, create new documents, and update successfully. However, when I want to download a large file (> 10mb) from Google Document, it causes OutOfMemoryError.

03-30 17:57:10.650: E/AndroidRuntime(11022): java.lang.OutOfMemoryError
03-30 17:57:10.650: E/AndroidRuntime(11022): at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:91)
03-30 17:57:10.650: E/AndroidRuntime(11022): at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:201)
03-30 17:57:10.650: E/AndroidRuntime(11022): at com.google.api.client.http.AbstractInputStreamContent.copy(AbstractInputStreamContent.java:213)
03-30 17:57:10.650: E/AndroidRuntime(11022): at com.google.api.client.http.AbstractInputStreamContent.copy(AbstractInputStreamContent.java:179)
03-30 17:57:10.650: E/AndroidRuntime(11022): at com.google.api.client.http.HttpResponse.getContent(HttpResponse.java:384)
This is my code:

try {
...
HttpRequest request = getRequestFactory().buildGetRequest(link);
HttpResponse response = request.execute();
InputStream is = response.getContent();
...
} catch (IOException e) {
e.printStackTrace();
}

The response code is 200, and it can work successfully on small files. Is there any method to download a large file using google-api-java-client? How would you expect it to be fixed? No OutOfMemoryError.

Original issue: http://code.google.com/p/google-http-java-client/issues/detail?id=82

@wonderfly wonderfly added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. imported priority: p0 Highest priority. Critical issue. P0 implies highest priority. labels Jan 9, 2015
@wonderfly wonderfly self-assigned this Jan 9, 2015
@wonderfly
Copy link
Contributor Author

From rmis...@google.com on April 19, 2012 04:48:16

I am not sure if we can fix this for when logging is enabled.
To log the content we have to store it in memory in a ByteArrayOutputStream especially because we need to convert it back into an InputStream for content. We cannot store only the content limit else when we convert it back into an InputStream it will have missing information. Please advice, thank you.

@wonderfly
Copy link
Contributor Author

From yan...@google.com on April 25, 2012 15:34:14

I'll take it. We can use FilteredInputStream and FilteredOutputStream.

Owner: yan...@google.com
Cc: rmis...@google.com
Labels: Component-HTTP

@wonderfly
Copy link
Contributor Author

From yan...@google.com on April 26, 2012 09:31:07

http://codereview.appspot.com/6123059/

Status: Started

@wonderfly
Copy link
Contributor Author

From yan...@google.com on April 27, 2012 09:13:12

Status: Fixed

@wonderfly
Copy link
Contributor Author

From soumi.ak...@gmail.com on May 30, 2012 07:24:03

Hello. I use this api ver. 1.9.0. but the issue seems not resolved.
Please see followings.

java.lang.OutOfMemoryError
at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:91)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:216)
at org.apache.harmony.luni.internal.net.www.protocol.http.RetryableOutputStream.write(RetryableOutputStream.java:60)
at com.google.api.client.http.AbstractInputStreamContent.copy(AbstractInputStreamContent.java:213)
at com.google.api.client.http.AbstractInputStreamContent.writeTo(AbstractInputStreamContent.java:78)
at com.google.api.client.http.MultipartRelatedContent.writeTo(MultipartRelatedContent.java:124)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:81)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:842)

this is occurred at...

private final HttpResponse execute(HttpRequest request) throws IOException {
prepare(request);
request.setContentLoggingLimit(0);
return request.execute(); <--HERE
}

above code is almost same to sample code.
am I wrong?

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Apr 7, 2020
clundin25 pushed a commit to clundin25/google-http-java-client that referenced this issue Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p0 Highest priority. Critical issue. P0 implies highest priority. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants