heap corruption detected by dlmalloc
现在走着走着,程序就直接崩掉了,报错日志如下:
11-17 23:22:27.523 19727-19727/com.handsome.hxm I/System.out: 这是个编辑器
11-17 23:22:27.523 19727-19727/com.handsome.hxm I/System.out: 这是个编辑器
11-17 23:22:27.523 19727-22572/com.handsome.hxm I/System.out: 230 User logged in, proceed.
11-17 23:22:27.523 19727-22572/com.handsome.hxm I/System.out: TYPE I
11-17 23:22:27.523 19727-22574/com.handsome.hxm I/System.out: 220 Serv-U FTP Server v15.1 ready...
11-17 23:22:27.523 19727-22556/com.handsome.hxm I/System.out: 150 Opening BINARY mode data connection for 5eaa48cf00321a6d022d4626652764bd.png (6833 Bytes).
11-17 23:22:27.523 19727-22574/com.handsome.hxm I/System.out: USER admin
11-17 23:22:27.523 19727-22573/com.handsome.hxm I/System.out: 230 User logged in, proceed.
11-17 23:22:27.523 19727-22566/com.handsome.hxm I/System.out: 227 Entering Passive Mode (192,168,0,31,5,111)
11-17 23:22:27.523 19727-22567/com.handsome.hxm I/System.out: 227 Entering Passive Mode (192,168,0,31,5,112)
11-17 23:22:27.523 19727-19727/com.handsome.hxm I/System.out: 这是个编辑器
[ 11-17 23:22:27.523 19727:22576 I/ ]
要请求的data:{"height":39,"width":249,"htmlContent":"2.库存现金收支业务的账务处理<\/strong><\/span><\/p><\/div>"}
11-17 23:22:27.523 19727-22573/com.handsome.hxm I/System.out: TYPE I
11-17 23:22:27.533 19727-22576/com.handsome.hxm W/System.err: [DEBUG] GbaRequest - GbaRequest: Constructor Called 222 userAgent null
11-17 23:22:27.533 19727-22556/com.handsome.hxm I/System.out: 下载进度:100
11-17 23:22:27.533 19727-22572/com.handsome.hxm I/System.out: 200 Type set to I.
11-17 23:22:27.533 19727-22572/com.handsome.hxm I/System.out: SYST
11-17 23:22:27.533 19727-22576/com.handsome.hxm W/System.err: [DEBUG] NafRequest - NafRequest: NafRequest constructor===useragent null
11-17 23:22:27.533 19727-19727/com.handsome.hxm A/libc: heap corruption detected by dlmalloc
11-17 23:22:27.533 19727-19727/com.handsome.hxm A/libc: Fatal signal 6 (SIGABRT) at 0x00004d0f (code=-6), thread 19727 (om.handsome.hxm)
报错就在最后两句,查了一下,其实就是thread开的过多,把heap整崩了而已
解决方案:
重新修改逻辑,将所有线程(Runnable)装到一个list中。开启一个线程池,里面最多装10个线程。同步下载,代码如图:
List onmList = DBManagerHelper.getInstance().getOnclassNode(common.tempUserId, common.tempCourseId);
if(onmList != null){
ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
common.runnableList.clear();
Log.i("","parse所有Node开始时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
for (OnclassNodeModel onm : onmList) {
try {
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/qinhan_inc/AndroidServer/" + onm.getNodeId() + ".html";
HtmlParserFullVersion parser = new HtmlParserFullVersion();
//解析html,将编辑器和图表代码发送到服务器,获取生成的图片ftp地址
parser.parseHtml(path);
} catch (Exception e) {
e.printStackTrace();
}
}
Log.i("","parse所有Node结束时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
Log.i("","common.runnableList size is:" + common.runnableList.size());
for (Runnable runnable : common.runnableList) {
fixedThreadPool.execute(runnable);
}
}
解决,就是得排队。