10-19 20:01:31.519 13234-13314/com.ztec.zsdecodedemo I/dalvikvm-heap: Clamp target GC heap from 98.656MB to 96.000MB
10-19 20:01:31.519 13234-13314/com.ztec.zsdecodedemo D/dalvikvm: GC_FOR_ALLOC freed <1K, 6% free 92488K/98248K, paused 36ms, total 36ms
10-19 20:01:31.519 13234-13314/com.ztec.zsdecodedemo I/dalvikvm-heap: Forcing collection of SoftReferences for 207952-byte allocation
10-19 20:01:31.569 13234-13314/com.ztec.zsdecodedemo I/dalvikvm-heap: Clamp target GC heap from 98.648MB to 96.000MB
10-19 20:01:31.569 13234-13314/com.ztec.zsdecodedemo D/dalvikvm: GC_BEFORE_OOM freed 9K, 6% free 92478K/98248K, paused 51ms, total 51ms
10-19 20:01:31.569 13234-13314/com.ztec.zsdecodedemo E/dalvikvm-heap: Out of memory on a 207952-byte allocation.
10-19 20:01:31.579 13234-13314/com.ztec.zsdecodedemo I/dalvikvm: "Thread-1386" prio=5 tid=11 RUNNABLE
10-19 20:01:31.579 13234-13314/com.ztec.zsdecodedemo I/dalvikvm: | group="main" sCount=0 dsCount=0 obj=0x419ac610 self=0x5ecf76a0
10-19 20:01:31.579 13234-13314/com.ztec.zsdecodedemo I/dalvikvm: | sysTid=13314 nice=0 sched=0/0 cgrp=apps handle=1590655728
10-19 20:01:31.579 13234-13314/com.ztec.zsdecodedemo I/dalvikvm: | state=R schedstat=( 38014891932 9395330768 20231 ) utm=3747 stm=54 core=1
10-19 20:01:31.579 13234-13314/com.ztec.zsdecodedemo I/dalvikvm: at com.ztec.zsdecoderlib.zdecode.PlanarYUVLuminanceSource.getMatrix(PlanarYUVLuminanceSource.java:~74)
10-19 20:01:31.579 13234-13314/com.ztec.zsdecodedemo I/dalvikvm: at com.ztec.zsdecoderlib.zdecode.DecodeHandler.decode(DecodeHandler.java:103)
10-19 20:01:31.579 13234-13314/com.ztec.zsdecodedemo I/dalvikvm: at com.ztec.zsdecoderlib.zdecode.DecodeHandler.handleMessage(DecodeHandler.java:41)
10-19 20:01:31.579 13234-13314/com.ztec.zsdecodedemo I/dalvikvm: at android.os.Handler.dispatchMessage(Handler.java:99)
10-19 20:01:31.579 13234-13314/com.ztec.zsdecodedemo I/dalvikvm: at android.os.Looper.loop(Looper.java:137)
10-19 20:01:31.579 13234-13314/com.ztec.zsdecodedemo I/dalvikvm: at com.ztec.zsdecoderlib.zdecode.DecodeThread.run(DecodeThread.java:43)
10-19 20:01:31.579 13234-13314/com.ztec.zsdecodedemo W/dalvikvm: threadid=11: thread exiting with uncaught exception (group=0x4164c898)
10-19 20:01:31.579 13234-13314/com.ztec.zsdecodedemo E/AndroidRuntime: FATAL EXCEPTION: Thread-1386
java.lang.OutOfMemoryError
at com.ztec.zsdecoderlib.zdecode.PlanarYUVLuminanceSource.getMatrix(PlanarYUVLuminanceSource.java:74)
at com.ztec.zsdecoderlib.zdecode.DecodeHandler.decode(DecodeHandler.java:103)
at com.ztec.zsdecoderlib.zdecode.DecodeHandler.handleMessage(DecodeHandler.java:41)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at com.ztec.zsdecoderlib.zdecode.DecodeThread.run(DecodeThread.java:43)
10-19 20:01:32.099 13234-13234/com.ztec.zsdecodedemo D/MAin: surfaceDestroyed
10-19 20:06:31.629 13234-13314/com.ztec.zsdecodedemo I/Process: Sending signal. PID: 13234 SIG: 9
定位发现执行到下面红色注释位置, 是因为我每次调用的时候都new 的原因吗!!!!关键是有时执行好久不会有问题,有时候一会就崩溃了,大神在哪里
public byte[] getMatrix() {
int width = this.getWidth();
int height = this.getHeight();
if(width == this.dataWidth && height == this.dataHeight) {
Log.d(TAG, "getMatrix: +++++++666666");
return this.yuvData;
} else {
int area = width * height;
Log.d(TAG, "getMatrix: +++++++");
Log.d(TAG, "getMatrix: area=" + area); //此处LOG会有
byte[] matrix = new byte[area]; //问题应出现在此处
Log.d(TAG, "getMatrix: +++++++"); //LOG不再打印
int inputOffset = this.top * this.dataWidth + this.left + 0;
if(width == this.dataWidth) {
System.arraycopy(this.yuvData, inputOffset, matrix, 0, area);
return matrix;
} else {
byte[] yuv = this.yuvData;
for(int y = 0; y < height; ++y) {
int outputOffset = y * width;
System.arraycopy(yuv, inputOffset, matrix, outputOffset, width);
inputOffset += this.dataWidth;
}
return matrix;
}
}
}
1 个解决方案
#1
自己顶......
#1
自己顶......