jaredsburrows / android-gif-search

Gif LazyVerticalGrid MVVM using Dagger 2 + Hilt with Retrofit 2, Moshi, Kotlin Coroutines, JUnit, Espresso and Robolectric tests!

Home Page:https://play.google.com/store/apps/details?id=com.burrowsapps.gif.search

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OutOfMemoryError

jaredrummler opened this issue · comments

Searching for GIFs eventually causes an OutOfMemoryError. Maybe you should only load search results in onQueryTextSubmit(String) instead of onQueryTextChange(String).

09-15 17:45:23.160 18409-18480/burrows.apps.giphy.example E/PriorityExecutor: Request threw uncaught throwable
  java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Failed to allocate a 12550156 byte allocation with 3777264 free bytes and 3MB 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 12550156 byte allocation with 3777264 free bytes and 3MB until OOM
      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.cacheAndDecodeSourceData(DecodeJob.java:207)
      at com.bumptech.glide.load.engine.DecodeJob.decodeFromSourceData(DecodeJob.java:187)
      at com.bumptech.glide.load.engine.DecodeJob.decodeSource(DecodeJob.java:177)
      at com.bumptech.glide.load.engine.DecodeJob.decodeFromSource(DecodeJob.java:128)
      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) 

Thanks and good idea! I was hoping to filter and search while downloading new images. For now, I added largHeap here: d4ea82e#diff-84fb62e1c8a8f1b095012858ba4dc95dR26.

I am seeing a OOM on an API 19 emulator as well.

I have started loading smaller gifs and load regular images for thumbnials. This has increased the speed.

Have you seen this since? I am going to close this for now.