Simple-Gallery icon indicating copy to clipboard operation
Simple-Gallery copied to clipboard

OutOfMemory crash while scanning files on F-Droid/FOSS version

Open buttercookie42 opened this issue 2 years ago • 2 comments

Phone: Moto G4 Play with Android 6.0.1 and 2 GB RAM

Installed Simple-Gallery 6.27.2 and made only the following settings changes:

  1. Exclude both internal and external SD card root folders.
  2. Manually included one folder on my external SD card, which has a substantial number of images spread across a number of folders.
  3. Turn on sub-folder grouping.
  4. (Force a folder re-scan.)

Result: Eventually, Simple-Gallery crashes with an OOM error (see attached log). gallery-394-oom.log

08-05 17:23:23.180 20379 20422 E AndroidRuntime: FATAL EXCEPTION: Thread-3655
08-05 17:23:23.180 20379 20422 E AndroidRuntime: Process: com.simplemobiletools.gallery.pro, PID: 20379
08-05 17:23:23.180 20379 20422 E AndroidRuntime: java.lang.OutOfMemoryError: Failed to allocate a 262156 byte allocation with 2754056 free bytes and 2MB until OOM; failed due to fragmentation (required continguous free 266240 bytes where largest contiguous free 110592 bytes)
08-05 17:23:23.180 20379 20422 E AndroidRuntime: 	at java.util.HashMap.makeTable(HashMap.java:551)
08-05 17:23:23.180 20379 20422 E AndroidRuntime: 	at java.util.HashMap.clone(HashMap.java:244)
08-05 17:23:23.180 20379 20422 E AndroidRuntime: 	at com.simplemobiletools.gallery.pro.helpers.MediaFetcher.getFilesFrom(SourceFile:231)
08-05 17:23:23.180 20379 20422 E AndroidRuntime: 	at com.simplemobiletools.gallery.pro.activities.MainActivity.gotDirectories(SourceFile:112)
08-05 17:23:23.180 20379 20422 E AndroidRuntime: 	at com.simplemobiletools.gallery.pro.activities.MainActivity.access$gotDirectories(SourceFile)
08-05 17:23:23.180 20379 20422 E AndroidRuntime: 	at com.simplemobiletools.gallery.pro.activities.MainActivity$getDirectories$1.invoke(SourceFile:2)
08-05 17:23:23.180 20379 20422 E AndroidRuntime: 	at com.simplemobiletools.gallery.pro.activities.MainActivity$getDirectories$1.invoke(SourceFile:1)
08-05 17:23:23.180 20379 20422 E AndroidRuntime: 	at com.simplemobiletools.gallery.pro.extensions.ContextKt$getCachedDirectories$1.invoke(SourceFile:57)
08-05 17:23:23.180 20379 20422 E AndroidRuntime: 	at com.simplemobiletools.gallery.pro.extensions.ContextKt$getCachedDirectories$1.invoke(SourceFile:1)
08-05 17:23:23.180 20379 20422 E AndroidRuntime: 	at com.simplemobiletools.commons.helpers.ConstantsKt.ensureBackgroundThread$lambda-0(SourceFile)
08-05 17:23:23.180 20379 20422 E AndroidRuntime: 	at com.simplemobiletools.commons.helpers.ConstantsKt.a(SourceFile)
08-05 17:23:23.180 20379 20422 E AndroidRuntime: 	at com.simplemobiletools.commons.helpers.a.run(SourceFile)
08-05 17:23:23.180 20379 20422 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:818)

After switching back and forth between both versions, it looks like only the F-Droid (foss-release) version is affected – the proprietary-release seems to work fine.

buttercookie42 avatar Aug 05 '23 16:08 buttercookie42

guess it happens on proprietary too if you give the app the All Files access

tibbi avatar Aug 14 '23 16:08 tibbi

For me crashes on latest version, while playing videos (taken by camera) and browsing through them, on latest version. Oneplus 7, no physical sdcard, android 12, plenty of ram

Using folder view Group direct subfolders: off

It didn't crash on previous versions. I can easilly reproduce by playing videos, and swiping to next video while playing, several times

Caught the errors in logcat:

Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 675408 free bytes and 659KB until OOM, target footprint 402653184, growth limit 402653184" (VmSize 8170668 kB)

OutOfMemory error loading stream
  java.lang.OutOfMemoryError: Failed to allocate a 65552 byte allocation with 56760 free bytes and 55KB until OOM, target footprint 402653184, growth limit 402653184
      at a1.e.c(SourceFile:38)
      at x0.e0.g(SourceFile:9)
      at x0.e0.o(SourceFile:1)
      at x0.g0.a(Unknown Source:2)
      at d1.m0.a(Unknown Source:1)
      at x0.g0.d(Unknown Source:0)
      at u1.k.C(SourceFile:169)
      at u1.k.e(SourceFile:25)
      at x0.b.b(SourceFile:17)
      at x0.b0$a.a(SourceFile:169)
      at androidx.media3.exoplayer.upstream.Loader$d.run(SourceFile:52)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
      at java.lang.Thread.run(Thread.java:920)


Throwing OutOfMemoryError "Failed to allocate a 64 byte allocation with 48416 free bytes and 47KB until OOM, target footprint 402653184, growth limit 402653184; giving up on allocation because <1% of heap free after GC." (VmSize 8170668 kB)


FATAL EXCEPTION: ExoPlayer:Playback
Process: com.simplemobiletools.gallery.pro, PID: 25731
java.lang.OutOfMemoryError: Failed to allocate a 64 byte allocation with 48416 free bytes and 47KB until OOM, target footprint 402653184, growth limit 402653184; giving up on allocation because <1% of heap free after GC.
	at java.nio.DirectByteBuffer.asReadOnlyBuffer(DirectByteBuffer.java:189)
	at android.media.MediaCodec.getBuffer(Native Method)
	at android.media.MediaCodec.getOutputBuffer(MediaCodec.java:4066)
	at androidx.media3.exoplayer.mediacodec.b.n(Unknown Source:2)
	at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.W(SourceFile:106)
	at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(SourceFile:72)
	at b1.d.render(SourceFile:1)
	at androidx.media3.exoplayer.o0.o(SourceFile:97)
	at androidx.media3.exoplayer.o0.handleMessage(SourceFile:226)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loopOnce(Looper.java:233)
	at android.os.Looper.loop(Looper.java:344)
	at android.os.HandlerThread.run(HandlerThread.java:67)