appwrite / sdk-for-android

[READ-ONLY] Official Appwrite Android SDK 💚 🤖
https://appwrite.io
BSD 3-Clause "New" or "Revised" License
98 stars 21 forks source link

🐛 Bug Report: Storage getFileDownload fails for big file (1GB) due to OutOfMemoryError #44

Open joern-h opened 9 months ago

joern-h commented 9 months ago

👟 Reproduction steps

Download a big file (1GB) with getFileDownload

👍 Expected behavior

It should download the file.

There is a client.chunkedUpload i guess we also need a client.chunkedDownload

👎 Actual Behavior

Throws java.lang.OutOfMemoryError:

AndroidRuntime  E  FATAL EXCEPTION: OkHttp Dispatcher
                E  java.lang.OutOfMemoryError: Failed to allocate a 268435472 byte allocation with 6275072 free bytes and 124MB until OOM, target footprint 143753320, growth limit 268435456
                E      at java.util.Arrays.copyOf(Arrays.java:3161)
                E      at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
                E      at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
                E      at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
                E      at kotlin.io.ByteStreamsKt.copyTo(IOStreams.kt:108)
                E      at kotlin.io.ByteStreamsKt.copyTo$default(IOStreams.kt:103)
                E      at kotlin.io.ByteStreamsKt.readBytes(IOStreams.kt:136)
                E      at io.appwrite.Client$awaitResponse$2$1.onResponse(Client.kt:511)
                E      at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
                E      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                E      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                E      at java.lang.Thread.run(Thread.java:919)

🎲 Appwrite version

Version 1.4.x

💻 Operating system

Linux

🧱 Your Environment

Appwrite 1.4.5 sdk-for-android:4.0.0

👀 Have you spent some time to check if this issue has been raised before?

🏢 Have you read the Code of Conduct?