leecade / leecade/react-native-swiper
OutOfMemoryError when there are a lot of <Image/> in the slides
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.5k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Which OS ?
Android
Version
Which versions are you using:
1.5.13
- react-native-swiper v?
- react-native v0.47.2
Expected behaviour
Using this code, just modify imgList to contain a lot of jpeg files located in the device's external storage (SD Card). It is expected to load through 'til the end of the list
https://github.com/leecade/react-native-swiper/blob/master/examples/components/LoadMinimal/index.js
Actual behaviour
After a few images (around 20+), the app crashed.
Logcat shows this error:
E/art (23532): Throwing OutOfMemoryError "Failed to allocate a 4041612 byte allocation with 3855344 free bytes and 3MB until OOM"
E/AndroidRuntime(23532): FATAL EXCEPTION: Thread-1654
E/AndroidRuntime(23532): Process: com.example.app, PID: 23532
E/AndroidRuntime(23532): java.lang.OutOfMemoryError: Failed to allocate a 4041612 byte allocation with 3855344 free bytes and 3MB until OOM
E/AndroidRuntime(23532): at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
E/AndroidRuntime(23532): at android.graphics.Bitmap.nativeCreate(Native Method)
E/AndroidRuntime(23532): at android.graphics.Bitmap.createBitmap(Bitmap.java:939)
E/AndroidRuntime(23532): at android.graphics.Bitmap.createBitmap(Bitmap.java:912)
E/AndroidRuntime(23532): at android.graphics.Bitmap.createBitmap(Bitmap.java:879)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.memory.BitmapPool.alloc(BitmapPool.java:55)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.memory.BitmapPool.alloc(BitmapPool.java:30)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.memory.BasePool.get(BasePool.java:259)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.platform.ArtDecoder.decodeStaticImageFromStream(ArtDecoder.java:137)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.platform.ArtDecoder.decodeJPEGFromEncodedImage(ArtDecoder.java:120)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.decoder.DefaultImageDecoder.decodeJpeg(DefaultImageDecoder.java:183)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.decoder.DefaultImageDecoder$1.decode(DefaultImageDecoder.java:63)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.decoder.DefaultImageDecoder.decode(DefaultImageDecoder.java:123)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder.doDecode(DecodeProducer.java:239)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder.access$200(DecodeProducer.java:111)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder$1.run(DecodeProducer.java:144)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.producers.JobScheduler.doJob(JobScheduler.java:207)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.producers.JobScheduler.access$000(JobScheduler.java:27)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.producers.JobScheduler$1.run(JobScheduler.java:78)
E/AndroidRuntime(23532): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime(23532): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime(23532): at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:43)
E/AndroidRuntime(23532): at java.lang.Thread.run(Thread.java:818)
How to reproduce it>
To help us, please fork this component, modify one example in examples folder to reproduce your issue and include link here.
- just add a lot more entries to
imgListin the specified example
Steps to reproduce
- scroll
- scroll 'til it crashed
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with examples/components/LoadMinimal/index.js and its imgList, then reproduce on Android with many JPEGs from external storage while monitoring Logcat. Trace the image-loading behavior associated with the example and determine why scrolling through the list exhausts memory; done means the full list loads without an OutOfMemoryError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100