在Windows机器上运行Appium Android测试脚本执行时,我们看到Java堆空间异常。我们使用Apache POI进行测试数据表阅读。直到第11个脚本套件运行正常,从第12个脚本开始看到Java堆空间异常。java.lang.OutOfMemoryError:Java堆空间 - Appium - TestNG Suite
我在Eclipse中增加了系统环境变量和TestNG Run Configuration中的堆和预留空间enter code here
。有时候没有问题,有时会遇到Java堆空间异常。
随着下面的消息我怀疑使用fileinputstream读取测试数据表,基于其他论坛,它加载时需要更多的内存,虽然测试数据没有大量的数据。我已经使用
代码是:
File strExecutionConfigFile = new File(
strImportedExecutionConfigFilePath);
try {
strInputExecutionConfigFile = new FileInputStream(
strExecutionConfigFile);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
objExecutionConfigWKB = new XSSFWorkbook(
strInputExecutionConfigFile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我看到XSSF读者格式将消耗低内存。可以在此提供代码。
您可以访问以下链接,Java堆空间异常
https://app.box.com/s/9t3or72lk44liolz8x22n9s0pk2klrna