---
title: "奇怪的AppCrash问题"
author: "sswh"
date: "2015-12-18T17:14:54Z"
tags: []
categories: ["编程语言"]
slug: "appcrash"
draft: false
lastmod: "2015-12-18T17:14:54Z"
id: 2265077
url: "https://sswh.iteye.com/blog/2265077"
---

最近发现项目会出现AppCrash问题。

 

经过同事提供的AppCrash的线索（和日志相关），经过定位、剥离无关影响因素，

最后得到最基本的代码如下：

 

```
public static void main(String[] args) throws Exception {
	byte[] bs = new byte[63000];
	for (int i = 0; i < bs.length; i++) {
		bs[i] = (byte) i;
	}
	System.out.write(("写入" + bs.length + "字节 ----------------").getBytes());
	System.out.write(bs);
	//System.out.print(new String(bs));
	System.out.write(("写入" + bs.length + "字节完成 ----------------").getBytes());
	int n = System.in.read();
	System.out.println(n);
}
```

 这一段代码在Win7 64位环境 + JRE1.6\_0\_43 64位版下面会导致AppCrash；（第一次可能不出现，第二次运行就会出现AppCrash）

 更换JRE8以后，Crash问题仍然存在。

 更换到Win2008 64位环境，Crash问题仍然存在。

 但是在Windows 8 下面，这段代码是正常执行的。

 

 真是奇怪了，是我的环境有问题吗？

 BTW， 为什么有上面的测试代码，因为logback在写控制台日志的时候，是使用outputStream.write()方法的。详见：ch.qos.logback.core.encoder.LayoutWrappingEncoder