Apeplan / gifview2

Automatically exported from code.google.com/p/gifview2
0 stars 0 forks source link

还是发现有OOM的问题 #1

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
首先非常感谢作者对gifview再次进行了优化,感谢作者付出的努
力。不过我在调试过程中发现对于某些图片还是存在OOM的问��
�。

不知道作者有没有考虑过对gif图片的解码部分用c来处理呢。�
��反编译了快图,发现它的gif图片显示部分是用jni来处理的,图�
��解码是用c写的。它的解码速度很快,也没有OOM的问题。不过�
��对NDK没有啥研究,只能抛砖引玉了。

以下是异常信息,附件中是调试用的gif图片:
06-28 13:56:22.320: W/System.err(20804): java.lang.OutOfMemoryError
06-28 13:56:22.320: W/System.err(20804):    at 
android.graphics.Bitmap.nativeCreate(Native Method)
06-28 13:56:22.320: W/System.err(20804):    at 
android.graphics.Bitmap.createBitmap(Bitmap.java:687)
06-28 13:56:22.320: W/System.err(20804):    at 
android.graphics.Bitmap.createBitmap(Bitmap.java:707)
06-28 13:56:22.320: W/System.err(20804):    at 
com.ant.liao.GifDecoder.setPixels(GifDecoder.java:323)
06-28 13:56:22.320: W/System.err(20804):    at 
com.ant.liao.GifDecoder.readImage(GifDecoder.java:775)
06-28 13:56:22.320: W/System.err(20804):    at 
com.ant.liao.GifDecoder.readContents(GifDecoder.java:665)
06-28 13:56:22.320: W/System.err(20804):    at 
com.ant.liao.GifDecoder.readStream(GifDecoder.java:406)
06-28 13:56:22.320: W/System.err(20804):    at 
com.ant.liao.GifDecoder.run(GifDecoder.java:163)
06-28 13:56:22.450: I/dalvikvm-heap(20804): Clamp target GC heap from 65.647MB 
to 64.000MB
06-28 13:56:22.450: D/dalvikvm(20804): GC_FOR_ALLOC freed 7K, 3% free 
64140K/65479K, paused 15ms, total 16ms
06-28 13:56:22.450: I/dalvikvm-heap(20804): Forcing collection of 
SoftReferences for 448016-byte allocation
06-28 13:56:22.470: I/dalvikvm-heap(20804): Clamp target GC heap from 65.647MB 
to 64.000MB
06-28 13:56:22.470: D/dalvikvm(20804): GC_BEFORE_OOM freed <1K, 3% free 
64140K/65479K, paused 22ms, total 22ms
06-28 13:56:22.470: E/dalvikvm-heap(20804): Out of memory on a 448016-byte 
allocation.
06-28 13:56:22.470: I/dalvikvm(20804): "Thread-561" prio=5 tid=11 RUNNABLE
06-28 13:56:22.470: I/dalvikvm(20804):   | group="main" sCount=0 dsCount=0 
obj=0x42601058 self=0x5a8476a8
06-28 13:56:22.470: I/dalvikvm(20804):   | sysTid=27553 nice=0 sched=0/0 
cgrp=apps handle=1517465528
06-28 13:56:22.470: I/dalvikvm(20804):   | schedstat=( 6718933635 737705528 
5676 ) utm=612 stm=59 core=0
06-28 13:56:22.470: I/dalvikvm(20804):   at 
android.graphics.Bitmap.nativeCreate(Native Method)
06-28 13:56:22.470: I/dalvikvm(20804):   at 
android.graphics.Bitmap.createBitmap(Bitmap.java:687)
06-28 13:56:22.470: I/dalvikvm(20804):   at 
android.graphics.Bitmap.createBitmap(Bitmap.java:707)
06-28 13:56:22.470: I/dalvikvm(20804):   at 
com.ant.liao.GifDecoder.setPixels(GifDecoder.java:323)
06-28 13:56:22.470: I/dalvikvm(20804):   at 
com.ant.liao.GifDecoder.readImage(GifDecoder.java:775)
06-28 13:56:22.470: I/dalvikvm(20804):   at 
com.ant.liao.GifDecoder.readContents(GifDecoder.java:665)
06-28 13:56:22.470: I/dalvikvm(20804):   at 
com.ant.liao.GifDecoder.readStream(GifDecoder.java:406)
06-28 13:56:22.470: I/dalvikvm(20804):   at 
com.ant.liao.GifDecoder.run(GifDecoder.java:163)

Original issue reported on code.google.com by Alibaba...@gmail.com on 28 Jun 2013 at 7:21

Attachments:

GoogleCodeExporter commented 8 years ago
我这边用你的图来测试,没有出现OOM,不知道你那边是什么��
�的环境。
至于解码的c处理部分,我已经完成了用c对gif来解码,因为这
段时间比较忙,等我自己测试过后会放出来

Original comment by liao.cy....@gmail.com on 9 Aug 2013 at 2:39

GoogleCodeExporter commented 8 years ago
避免OOM,你可以在以下方法中加入这几行就可以了(在GifView.
java中)
private int getCurrentFrame() {
        // 如果当前帧不为空的话,销毁当前帧里的bitmap对象
        if (null != currentImage) {
            currentImage.recycle();
            currentImage = null;
        }
        // 后面的不变
    }

附件中是加这几行与不加这几行之间的区别

Original comment by xiang....@gmail.com on 9 Jan 2014 at 2:09

Attachments:

GoogleCodeExporter commented 8 years ago
附加上我测试用的gif文件,1.7M的gif图片,不算小

Original comment by xiang....@gmail.com on 9 Jan 2014 at 2:11

Attachments:

GoogleCodeExporter commented 8 years ago

@  xiang....@gmail.com   

下面的方法 什么时候调用呢?
private void getCurrentFrame() {
        // 如果当前帧不为空的话,销毁当前帧里的bitmap对象
        if (null != currentImage) {
            currentImage.recycle();
            currentImage = null;
        }
        // 后面的不变

    }

Original comment by li710...@gmail.com on 24 Dec 2014 at 6:18