fresco icon indicating copy to clipboard operation
fresco copied to clipboard

OutOfMemoryError: Failed to allocate a 251648770 byte allocation [Local large images allocation issue]

Open zetbrush opened this issue 1 year ago • 2 comments

Description

For local files (images) which are pretty large on size (e.g. 180 - 300 MB PNGs), fresco tries to allocate exact the same ByteBuffer at LocalFetchProducer, before creating EncodedImage instance, thus leading to instantly OOM

Reproduction

  • Download large png from https://visibleearth.nasa.gov/images/73884/november-blue-marble-next-generation-w-topography-and-bathymetry (larger 200MB)
  • try loading those images in some image picker grid layout

stacktrace

FATAL EXCEPTION: FrescoIoBoundExecutor-2 Process: com.p.s, PID: 24581 java.lang.OutOfMemoryError: Failed to allocate a 251648770 byte allocation with 100663296 free bytes and 469MB until OOM, target footprint 145550240, growth limit 536870912 at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at java.nio.DirectByteBuffer$MemoryRef.<init>(DirectByteBuffer.java:70) at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:260) at com.facebook.imagepipeline.memory.BufferMemoryChunk.<init>(BufferMemoryChunk.java:38) at com.facebook.imagepipeline.memory.BufferMemoryChunkPool.alloc(BufferMemoryChunkPool.java:31) at com.facebook.imagepipeline.memory.BufferMemoryChunkPool.alloc(BufferMemoryChunkPool.java:16) at com.facebook.imagepipeline.memory.BasePool.get(BasePool.java:256) at com.facebook.imagepipeline.memory.MemoryPooledByteBufferOutputStream.<init>(MemoryPooledByteBufferOutputStream.java:55) at com.facebook.imagepipeline.memory.MemoryPooledByteBufferFactory.newByteBuffer(MemoryPooledByteBufferFactory.java:75) at com.facebook.imagepipeline.memory.MemoryPooledByteBufferFactory.newByteBuffer(MemoryPooledByteBufferFactory.java:25) at com.facebook.imagepipeline.producers.LocalFetchProducer.getByteBufferBackedEncodedImage(LocalFetchProducer.java:83) at com.facebook.imagepipeline.producers.LocalFetchProducer.getEncodedImage(LocalFetchProducer.java:93) at com.facebook.imagepipeline.producers.LocalFileFetchProducer.getEncodedImage(LocalFileFetchProducer.java:33) at com.facebook.imagepipeline.producers.LocalFetchProducer$1.getResult(LocalFetchProducer.java:47) at com.facebook.imagepipeline.producers.LocalFetchProducer$1.getResult(LocalFetchProducer.java:43) at com.facebook.common.executors.StatefulRunnable.run(StatefulRunnable.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:52) at java.lang.Thread.run(Thread.java:1012)

Additional Information

  • Fresco version: [2.6.0]
  • Platform version: on latest OS/ Hi end device (non platform specific)

zetbrush avatar Jun 22 '23 13:06 zetbrush

cc @oprisnik

zetbrush avatar Jun 28 '23 11:06 zetbrush

Hey, any news on this? cc @cortinico @defHLT

zetbrush avatar Nov 01 '23 07:11 zetbrush