heap corruption detected by dlmalloc

原生看书,下载完整版,解析所有html,抽取出所有编辑器,拿着内容去服务器获取图片路径,然后再通过路径去去下载文件,

现在走着走着,程序就直接崩掉了,报错日志如下:

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":"<div class=\"editor\" id=\"editor76\"><p style=\"line-height: 1.5em;\"><span style=\"font-family: 宋体, SimSun; font-size: 16px; color: #244061;\"><strong>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<OnclassNodeModel> 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);
		}
}
解决,就是得排队。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值