Glide: Out of memory exception gif

Created on 4 May 2016  路  2Comments  路  Source: bumptech/glide

E/PriorityExecutor: Request threw uncaught throwable
  java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Failed to allocate a 6337368 byte allocation with 5143040 free bytes and 4MB until OOM
      at java.util.concurrent.FutureTask.report(FutureTask.java:94)
      at java.util.concurrent.FutureTask.get(FutureTask.java:164)
      at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor.afterExecute(FifoPriorityThreadPoolExecutor.java:96)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1121)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
      at java.lang.Thread.run(Thread.java:818)
      at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor$DefaultThreadFactory$1.run(FifoPriorityThreadPoolExecutor.java:118)
   Caused by: java.lang.OutOfMemoryError: Failed to allocate a 6337368 byte allocation with 5143040 free bytes and 4MB until OOM
      at com.bumptech.glide.gifencoder.AnimatedGifEncoder.getImagePixels(AnimatedGifEncoder.java:384)
      at com.bumptech.glide.gifencoder.AnimatedGifEncoder.addFrame(AnimatedGifEncoder.java:161)
      at com.bumptech.glide.load.resource.gif.GifResourceEncoder.encode(GifResourceEncoder.java:64)
      at com.bumptech.glide.load.resource.gif.GifResourceEncoder.encode(GifResourceEncoder.java:25)
      at com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResourceEncoder.encode(GifBitmapWrapperResourceEncoder.java:34)
      at com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResourceEncoder.encode(GifBitmapWrapperResourceEncoder.java:15)
      at com.bumptech.glide.load.engine.DecodeJob$SourceWriter.write(DecodeJob.java:270)
      at com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper.put(DiskLruCacheWrapper.java:98)
      at com.bumptech.glide.load.engine.DecodeJob.writeTransformedToCache(DecodeJob.java:160)
      at com.bumptech.glide.load.engine.DecodeJob.transformEncodeAndTranscode(DecodeJob.java:144)
      at com.bumptech.glide.load.engine.DecodeJob.decodeFromSource(DecodeJob.java:129)
      at com.bumptech.glide.load.engine.EngineRunnable.decodeFromSource(EngineRunnable.java:122)
      at com.bumptech.glide.load.engine.EngineRunnable.decode(EngineRunnable.java:101)
      at com.bumptech.glide.load.engine.EngineRunnable.run(EngineRunnable.java:58)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)聽
      at java.lang.Thread.run(Thread.java:818)聽
      at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor$DefaultThreadFactory$1.run(FifoPriorityThreadPoolExecutor.java:118)

when trying to load a gif from the file system on a Nexus 6 running Android 6.0.1 MHC19Q.
the code that throws the exception is:

Glide.with(mContext)
        .load(mImage.getPath())
        .placeholder(R.drawable.placeholder)
        .centerCrop()
        .into(holder.mImage);

mImage is confirmed to be a gif before running this code.
this code is being runned in the onBindViewHolder method of a custom RecyclerView.Adapter.
and for the layout code:

<RelativeLayout
         <ImageView
                <LinearLayout

EDIT:
also, sometimes the error occures, sometimes it doesnt.
9 out of 10 times the .gif just wont load.

question

Most helpful comment

sometimes the error occures, sometimes it doesnt.

That's the nature of OOMs usually.

You're getting the OOM from encoder, because it tries to resize the GIF, try adding .diskCacheStrategy(SOURCE). It should speed up loading/decoding a lot and hopefully gets rid of the OOM as well.

All 2 comments

sometimes the error occures, sometimes it doesnt.

That's the nature of OOMs usually.

You're getting the OOM from encoder, because it tries to resize the GIF, try adding .diskCacheStrategy(SOURCE). It should speed up loading/decoding a lot and hopefully gets rid of the OOM as well.

thnx, worked out great

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kenneth2008 picture kenneth2008  路  3Comments

MrFuFuFu picture MrFuFuFu  路  3Comments

ghost picture ghost  路  3Comments

technoir42 picture technoir42  路  3Comments

sergeyfitis picture sergeyfitis  路  3Comments