WGDrzjz / ImageCompress

图片压缩工具,基于libjpeg-turbo封装,arm64-v8a和armeabi-v7a都可以正常使用。
51 stars 13 forks source link

文件超过2个,非常容易OOM,是我哪里操作不对吗? #2

Open nuxwork opened 5 years ago

nuxwork commented 5 years ago
11-11 22:25:18.625 19957-20221/com.nxztsckj.nkygq E/art: Throwing OutOfMemoryError "Failed to allocate a 52047884 byte allocation with 4194208 free bytes and 22MB until OOM"
11-11 22:25:18.626 19957-20221/com.nxztsckj.nkygq E/AndroidRuntime: FATAL EXCEPTION: Thread-1806
    Process: com.nxztsckj.nkygq, PID: 19957
    java.lang.OutOfMemoryError: Failed to allocate a 52047884 byte allocation with 4194208 free bytes and 22MB until OOM
        at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
        at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
        at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:677)
        at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:653)
        at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:433)
        at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:459)
        at com.wgd.gdcp.gdcplibrary.GDBitmapUtil.bitmapDegree(GDBitmapUtil.java:68)
        at com.wgd.gdcp.gdcplibrary.GDCompressC$1.run(GDCompressC.java:87)
        at java.lang.Thread.run(Thread.java:818)
FlyingYu-Z commented 5 years ago

我也遇到了OOM,我压缩的文件是5个,报错如下: java.lang.OutOfMemoryError: Failed to allocate a 2073612 byte allocation with 1164040 free bytes and 1136KB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:677) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:653) at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:433) at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:459) at com.wgd.gdcp.gdcplibrary.GDBitmapUtil.bitmapDegree(GDBitmapUtil.java:68) at com.wgd.gdcp.gdcplibrary.GDCompressImageS$100000000.run(GDCompressImageS.java:102) at java.lang.Thread.run(Thread.java:818)

WGDrzjz commented 5 years ago

由于前段时间比较忙,而且公司使用一直没有问题,所以这个项目一直没有优化。现在终于抽出时间来搞了一下。目前1.0.10版本已经提供多种方式优化OOM问题。欢迎继续使用、讨论。