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 for gif big #1300

Closed
fanweiguo opened this issue Jul 1, 2016 · 3 comments
Closed

OutOfMemoryError for gif big #1300

fanweiguo opened this issue Jul 1, 2016 · 3 comments
Labels

Comments

@fanweiguo
Copy link

fanweiguo commented Jul 1, 2016

Glide Version:

Integration libraries:

Device/Android Version:

Issue details / Repro steps / Use case background:

Glide load line / GlideModule (if any) / list Adapter code (if any):

Glide.with...

Layout XML:

<FrameLayout xmlns:android="...

Stack trace / LogCat:

java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError
    at java.util.concurrent.FutureTask.report(FutureTask.java:94)
    at java.util.concurrent.FutureTask.get(FutureTask.java:160)
    at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor.afterExecute(FifoPriorityThreadPoolExecutor.java:96)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
    at java.lang.Thread.run(Thread.java:841)
    at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor$DefaultThreadFactory$1.run(FifoPriorityThreadPoolExecutor.java:118)
 Caused by: java.lang.OutOfMemoryError
    at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:91)
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:201)
    at com.bumptech.glide.load.resource.gif.GifResourceDecoder.inputStreamToBytes(GifResourceDecoder.java:106)
    at com.bumptech.glide.load.resource.gif.GifResourceDecoder.decode(GifResourceDecoder.java:57)
    at com.bumptech.glide.load.resource.gif.GifResourceDecoder.decode(GifResourceDecoder.java:26)
    at com.bumptech.glide.load.resource.file.FileToStreamDecoder.decode(FileToStreamDecoder.java:39)
    at com.bumptech.glide.load.resource.file.FileToStreamDecoder.decode(FileToStreamDecoder.java:17)
    at com.bumptech.glide.load.engine.DecodeJob.loadFromCache(DecodeJob.java:222)
    at com.bumptech.glide.load.engine.DecodeJob.decodeSourceFromCache(DecodeJob.java:109)
    at com.bumptech.glide.load.engine.EngineRunnable.decodeFromCache(EngineRunnable.java:116)
    at com.bumptech.glide.load.engine.EngineRunnable.decode(EngineRunnable.java:99)
    at com.bumptech.glide.load.engine.EngineRunnable.run(EngineRunnable.java:58)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
    at java.lang.Thread.run(Thread.java:841) 
    at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor$DefaultThreadFactory$1.run(FifoPriorityThreadPoolExecutor.java:118) 
@fanweiguo
Copy link
Author

已经设置了diskCacheStrategy(DiskCacheStrategy.SOURCE), but not useful,please help look

@TWiStErRob
Copy link
Collaborator

The full GIF file will be loaded into memory + 2 frames will be needed to show the animation (1 displayed, 1 loading, then swap). If your source GIF is huge, it'll take up memory. If your GIF's resolution is huge it'll take up memory. There's no way around this. You can try .override() to load a smaller image, but it looks like it's failing before even having a chance to decode Bitmaps.

Try to do some normal OOM troubleshooting, it's possible you have a leak somewhere else, but it comes up here, because GIFs need a lot of memory.

@TWiStErRob
Copy link
Collaborator

Please add more details by editing your first comment, the device/android version may give a clue about how big your available memory is for example.

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

No branches or pull requests

2 participants