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

Out Of Memory on file Download #1180

Closed
sumit-anantwar opened this issue Jul 1, 2016 · 1 comment
Closed

Out Of Memory on file Download #1180

sumit-anantwar opened this issue Jul 1, 2016 · 1 comment

Comments

@sumit-anantwar
Copy link

sumit-anantwar commented Jul 1, 2016

I am trying to download a .tgz archive of 50mb, and I am getting OOM on Samsung Galaxy Tab 2. But the file downloads without any issues on more recent devices and also on the simulator.
Seems that the default buffer size is larger than the available free memory on older devices.
Is there a way to specify the buffer size ?

07-02 17:25:27.250 4725-4725 I/DataFetcher: Retry count : 1
07-02 17:25:28.257 4725-5216 D/dalvikvm: GC_FOR_ALLOC freed 48K, 23% free 8349K/10820K, paused 27ms, total 28ms
07-02 17:25:28.257 4725-5216 I/dalvikvm-heap: Forcing collection of SoftReferences for 41758031-byte allocation
07-02 17:25:28.289 4725-5216 D/dalvikvm: GC_BEFORE_OOM freed 0K, 23% free 8349K/10820K, paused 33ms, total 33ms
07-02 17:25:28.289 4725-5216 E/dalvikvm-heap: Out of memory on a 41758031-byte allocation.
07-02 17:25:28.289 4725-5216 I/dalvikvm: "pool-2-thread-1" prio=5 tid=13 RUNNABLE
07-02 17:25:28.296 4725-5216 I/dalvikvm:   | group="main" sCount=0 dsCount=0 obj=0x4284df50 self=0x5a21da30
07-02 17:25:28.296 4725-5216 I/dalvikvm:   | sysTid=5216 nice=0 sched=0/0 cgrp=apps handle=1512164168
07-02 17:25:28.296 4725-5216 I/dalvikvm:   | state=R schedstat=( 157897947 44738772 373 ) utm=14 stm=0 core=0
07-02 17:25:28.296 4725-5216 I/dalvikvm:     at cz.msebera.android.httpclient.util.ByteArrayBuffer.<init>(ByteArrayBuffer.java:~56)
07-02 17:25:28.296 4725-5216 I/dalvikvm:     at com.loopj.android.http.AsyncHttpResponseHandler.getResponseData(AsyncHttpResponseHandler.java:472)
07-02 17:25:28.296 4725-5216 I/dalvikvm:     at com.loopj.android.http.AsyncHttpResponseHandler.sendResponseMessage(AsyncHttpResponseHandler.java:442)
07-02 17:25:28.296 4725-5216 I/dalvikvm:     at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:160)
07-02 17:25:28.296 4725-5216 I/dalvikvm:     at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:177)
07-02 17:25:28.296 4725-5216 I/dalvikvm:     at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:106)
07-02 17:25:28.296 4725-5216 I/dalvikvm:     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
07-02 17:25:28.296 4725-5216 I/dalvikvm:     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-02 17:25:28.296 4725-5216 I/dalvikvm:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-02 17:25:28.296 4725-5216 I/dalvikvm:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-02 17:25:28.296 4725-5216 I/dalvikvm:     at java.lang.Thread.run(Thread.java:856)
07-02 17:25:28.335 4725-5216 E/dalvikvm: adjustAdaptiveCoef max=4194304, min=1048576, ut=568
07-02 17:25:28.335 4725-5216 D/dalvikvm: GC_EXPLICIT freed <1K, 23% free 8349K/10820K, paused 2ms+3ms, total 34ms
@smarek
Copy link
Member

smarek commented May 23, 2019

I'm sorry, but default AsyncHttpResponseHandler is not meant to handle such large data. Use FileAsyncHttpResponseHandler.java or provide your own ResponseHandler, that would stream the file directly to filesystem, instead of caching it in memory and writing it out later

@smarek smarek closed this as completed May 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants