简体   繁体   English

如何修复:java.lang.OutOfMemoryError:请求的数组大小超过 VM 限制,同时为项目运行 Junit

[英]How to fix : java.lang.OutOfMemoryError: Requested array size exceeds VM limit, while running Junit for a project

Getting below exception while running Junit , Not sure which part of code leading to this issue: (using ANT - 1.9.4, ANT_OPTS=-Xmx10G) ( )运行 Junit 时出现异常,不确定导致此问题的代码部分:(使用 ANT - 1.9.4,ANT_OPTS=-Xmx10G)()

Tests run: 544, Failures: 1, Errors: 0, Time elapsed: 10,258.816 sec

   [junit] Exception in thread "main" java.lang.OutOfMemoryError: Requested array size exceeds VM limit
   [junit]  at java.lang.StringCoding$StringEncoder.encode(StringCoding.java:300)
   [junit]  at java.lang.StringCoding.encode(StringCoding.java:344)
   [junit]  at java.lang.StringCoding.encode(StringCoding.java:387)
   [junit]  at java.lang.String.getBytes(String.java:958)
   [junit]  at org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter.endTestSuite(PlainJUnitResultFormatter.java:152)
   [junit]  at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.fireEndTestSuite(JUnitTestRunner.java:619)
   [junit]  at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:452)
   [junit]  at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:911)
   [junit]  at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:768)

The exception is thrown after the tests are run and test report generation starts.运行测试并开始生成测试报告后会引发异常。

This is how junit is configured:这是 junit 的配置方式:

<junit fork="yes" newenvironment="false" haltonfailure="no" failureproperty="junit.failure" printsummary="yes" maxmemory="10096m">

Are you sure you are using ANT 1.9.4?您确定您使用的是 ANT 1.9.4 吗?

Your stacktrace matches the source code of PlainJUnitResultFormatter in ANT version 1.8.4:您的堆栈跟踪与 ANT 版本 1.8.4 中的PlainJUnitResultFormatter的源代码相匹配:

out.write(sb.toString().getBytes());

Whereas in the source code of PlainJUnitResultFormatter in ANT version 1.9.4:而在 ANT 版本 1.9.4 中的PlainJUnitResultFormatter的源代码中:

write(StringUtils.LINE_SEP);

there is no call of String.getBytes() where the exception occurs.在发生异常的地方没有调用String.getBytes()

The reason to ask is this comment from the ANT 1.9.4 release notes :询问的原因是来自ANT 1.9.4 发行说明的评论:

  • changes to JUnitTestRunner and PlainJUnitResultFormatter to make OutOfMemoryErrors less likely.更改 JUnitTestRunner 和 PlainJUnitResultFormatter 以降低 OutOfMemoryErrors 的可能性。 Bugzilla Report 45536 Bugzilla 报告 45536

So the solution would be to upgrade to ANT 1.9.4 or later所以解决方案是升级到 ANT 1.9.4 或更高版本

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么进程在错误后运行-java.lang.OutOfMemoryError:请求的数组大小超出了VM限制? - Why the processes runs after error - java.lang.OutOfMemoryError: Requested array size exceeds VM limit? 使用iText:java.lang.OutOfMemoryError:请求的数组大小超过VM限制 - Using iText: java.lang.OutOfMemoryError: Requested array size exceeds VM limit 线程“主”中的异常java.lang.OutOfMemoryError:请求的数组大小超出了VM限制 - Exception in thread “main” java.lang.OutOfMemoryError: Requested array size exceeds VM limit ObjectOutputStream-对象超过1GB会导致java.lang.OutOfMemoryError:请求的数组大小超出VM限制 - ObjectOutputStream - Object exceeding 1GB causes java.lang.OutOfMemoryError: Requested array size exceeds VM limit 线程“Thread”中的异常 java.lang.OutOfMemoryError:请求的数组大小超出 VM 限制 - Exception in thread "Thread" java.lang.OutOfMemoryError: Requested array size exceeds VM limit java.lang.OutOfMemoryError:请求的数组大小超出了Amazon Cloud中eclipse中的VM限制 - java.lang.OutOfMemoryError: Requested array size exceeds VM limit in eclipse in Amazon Cloud 如何修复Java中“请求的数组大小超过VM限制”错误? - How to fix “Requested array size exceeds VM limit” error in Java? java.lang.OutOfMemoryError:位图大小超过VM预算 - java.lang.OutOfMemoryError: bitmap size exceeds VM budget java.lang.OutOfMemoryError:位图大小超过第二次运行应用程序时VM预算崩溃 - java.lang.OutOfMemoryError: bitmap size exceeds VM budget crashes on second time running app 如何避免java.lang.OutOfMemoryError:在使用大位图时,位图大小超过了android中的VM预算? - How can I avoid java.lang.OutOfMemoryError: bitmap size exceeds VM budget in android while using a large bitmap?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM