[Bug] Full Backup OutOfMemoryError
Describe the bug
It seems like the application runs out of memory if you added too many novels and use full backup. I'm not exactly sure why it's trying to allocate about 150MB of storage when beginning the step encoding to json (at least android notification says it's there) when it uses way less before but on the other hand i'm no expert with the whole encoding to json implementation etc so take it with a grain of salt
To Reproduce
Steps to reproduce the behavior:
- Add lots of Novels
- Backup full
- '....'
- See error
Expected behavior
Execute Backup without Error ;)
Device information
- OS:13
- App Version: 2.4.4
Additional context
Logcat
09-07 13:14:18.650 14968 16603 I hosetsu.android: Alloc concurrent copying GC freed 20(16KB) AllocSpace objects, 0(0B) LOS objects, 37% free, 158MB/254MB, paused 29us,16us total 114.389ms
09-07 13:14:18.651 14968 16603 W hosetsu.android: Throwing OutOfMemoryError "Failed to allocate a 165786048 byte allocation with 100663296 free bytes and 97MB until OOM, target footprint 266659056, growth limit 268435456" (VmSize 32132176
kB)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: Work [ id=e0d254d5-a84c-48e1-a24a-33bef64f644d, tags={ app.shosetsu.android.backend.workers.onetime.BackupWorker } ] failed because it threw an exception/error
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Failed to allocate a 165786048 byte allocation with 100663296 free bytes and 97MB until OOM, target footprint 266659056, growth limit 268435456
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(SourceFile:21)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at androidx.work.impl.utils.futures.AbstractFuture.get(SourceFile:134)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at androidx.work.Worker$2.run(SourceFile:320)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at androidx.work.Worker$2.run$androidx$work$impl$utils$SerialExecutorImpl$Task(SourceFile:5)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at androidx.work.Worker$2.run(SourceFile:189)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at java.lang.Thread.run(Thread.java:1012)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: Caused by: java.lang.OutOfMemoryError: Failed to allocate a 165786048 byte allocation with 100663296 free bytes and 97MB until OOM, target footprint 266659056, growth limit 268435456
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at java.util.Arrays.copyOf(Arrays.java:3766)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.json.internal.JsonToStringWriter.ensureTotalCapacity(SourceFile:12)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.json.internal.Composer.printQuoted(SourceFile:19)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeString(SourceFile:8)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at coil.util.-Bitmaps.encodeStringElement(SourceFile:14)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at app.shosetsu.android.domain.model.local.backup.BackupChapterEntity$$serializer.serialize(SourceFile:2)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at app.shosetsu.android.domain.model.local.backup.BackupChapterEntity$$serializer.serialize(SourceFile:9)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(SourceFile:106)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at coil.util.-Bitmaps.encodeSerializableElement(SourceFile:14)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.internal.CollectionLikeSerializer.serialize(SourceFile:38)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(SourceFile:106)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at coil.util.-Bitmaps.encodeSerializableElement(SourceFile:14)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at app.shosetsu.android.domain.model.local.backup.BackupNovelEntity$$serializer.serialize(SourceFile:6)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at app.shosetsu.android.domain.model.local.backup.BackupNovelEntity$$serializer.serialize(SourceFile:12)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(SourceFile:106)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at coil.util.-Bitmaps.encodeSerializableElement(SourceFile:14)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.internal.CollectionLikeSerializer.serialize(SourceFile:38)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(SourceFile:106)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at coil.util.-Bitmaps.encodeSerializableElement(SourceFile:14)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at app.shosetsu.android.domain.model.local.backup.BackupExtensionEntity$$serializer.serialize(SourceFile:4)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at app.shosetsu.android.domain.model.local.backup.BackupExtensionEntity$$serializer.serialize(SourceFile:6)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(SourceFile:106)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at coil.util.-Bitmaps.encodeSerializableElement(SourceFile:14)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.internal.CollectionLikeSerializer.serialize(SourceFile:38)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(SourceFile:106)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at coil.util.-Bitmaps.encodeSerializableElement(SourceFile:14)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at app.shosetsu.android.domain.model.local.backup.FleshedBackupEntity$$serializer.serialize(SourceFile:8)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at app.shosetsu.android.domain.model.local.backup.FleshedBackupEntity$$serializer.serialize(SourceFile:12)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(SourceFile:106)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at okio.Utf8.encodeByWriter(SourceFile:42)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.serialization.json.Json.encodeToString(SourceFile:11)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at app.shosetsu.android.backend.workers.onetime.BackupWorker.doWork(SourceFile:2637)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at app.shosetsu.android.backend.workers.onetime.BackupWorker$doWork$1.invokeSuspend(Unknown Source:11)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(SourceFile:9)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.coroutines.DispatchedTask.run(SourceFile:116)
09-07 13:14:18.656 14968 15074 E WM-WorkerWrapper: at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(SourceFile:94)
09-07 13:14:18.657 14968 15074 I WM-WorkerWrapper: Worker result FAILURE for Work [ id=e0d254d5-a84c-48e1-a24a-33bef64f644d, tags={ app.shosetsu.android.backend.workers.onetime.BackupWorker } ]