penfeizhou / APNG4Android

Android animation support for APNG & Animated WebP & Gif & Animated AVIF, High performance
Apache License 2.0
570 stars 75 forks source link

Failed to allocate a 1698005176 byte allocation with 25165824 free bytes and 113MB until OOM #220

Closed 865240856 closed 2 months ago

865240856 commented 2 months ago

自己项目一直在报错,无法找到原因,加载的资源也不是很大,但报错需要申请1698005176byte这么多的内存,麻烦大佬看看

ByteBufferWriter.java:51 Caused by:com.github.penfeizhou.animation.io.ByteBufferWriter.reset Failed to allocate a 1698005176 byte allocation with 25165824 free bytes and 113MB until OOM, target footprint 174362856, growth limit 268435456 Fatal Exception:java.lang.OutOfMemoryError

### 堆栈如下:目前使用版本(2.28.0) java.nio.HeapByteBuffer.(HeapByteBuffer.java:54)

java.nio.HeapByteBuffer.(HeapByteBuffer.java:49)

java.nio.ByteBuffer.allocate(ByteBuffer.java:282)

com.github.penfeizhou.animation.io.ByteBufferWriter.reset(ByteBufferWriter.java:51)

com.github.penfeizhou.animation.apng.io.APNGWriter.reset(APNGWriter.java:33)

com.github.penfeizhou.animation.apng.decode.APNGFrame.encode(APNGFrame.java:79)

com.github.penfeizhou.animation.apng.decode.APNGFrame.draw(APNGFrame.java:135)

com.github.penfeizhou.animation.apng.decode.APNGFrame.draw(APNGFrame.java:23)

com.github.penfeizhou.animation.apng.decode.APNGDecoder.renderFrame(APNGDecoder.java:201)

com.github.penfeizhou.animation.decode.FrameSeqDecoder.step(FrameSeqDecoder.java:512)

com.github.penfeizhou.animation.decode.FrameSeqDecoder.access$200(FrameSeqDecoder.java:36)

com.github.penfeizhou.animation.decode.FrameSeqDecoder$1.run(FrameSeqDecoder.java:60)

com.github.penfeizhou.animation.decode.FrameSeqDecoder.innerStart(FrameSeqDecoder.java:317)

com.github.penfeizhou.animation.decode.FrameSeqDecoder.access$900(FrameSeqDecoder.java:36)

com.github.penfeizhou.animation.decode.FrameSeqDecoder$6.run(FrameSeqDecoder.java:287)

android.os.Handler.handleCallback(Handler.java:883)

android.os.Handler.dispatchMessage(Handler.java:100)

android.os.Looper.loop(Looper.java:223)

android.os.HandlerThread.run(HandlerThread.java:67)

penfeizhou commented 2 months ago

请提供有问题的文件后再排查问题.