Maven Cobertura 内存不足错误
我正在使用 Maven site:run 生成 cobertura 代码覆盖率...
以下是我的 cobertura 的 pom.xml 配置:
<reporting>
...
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>
但是,我在 site:run 末尾收到 OutOfMemoryError 。请建议如何消除此错误。 (我已经尝试了所有这些 -Xmx、-XX 选项...)
Exception in thread "Thread-0" java.lang.OutOfMemoryError: Java heap space
at sun.reflect.GeneratedSerializationConstructorAccessor74.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.io.ObjectStreamClass.newInstance(ObjectStreamClass.java:924)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1737)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at java.util.HashMap.readObject(HashMap.java:1030)
at sun.reflect.GeneratedMethodAccessor347.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480)
at net.sourceforge.cobertura.coveragedata.CoverageDataContainer.readObject(CoverageDataContainer.java:373)
at sun.reflect.GeneratedMethodAccessor348.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at java.util.HashMap.readObject(HashMap.java:1030)
at sun.reflect.GeneratedMethodAccessor347.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
I am using Maven site:run to generate a cobertura code coverage...
The following is my pom.xml configuration for cobertura:
<reporting>
...
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>
However I am getting OutOfMemoryError at the end of the site:run. Please suggest how to get rid of this error. (I have tried all those -Xmx, -XX options...)
Exception in thread "Thread-0" java.lang.OutOfMemoryError: Java heap space
at sun.reflect.GeneratedSerializationConstructorAccessor74.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.io.ObjectStreamClass.newInstance(ObjectStreamClass.java:924)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1737)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at java.util.HashMap.readObject(HashMap.java:1030)
at sun.reflect.GeneratedMethodAccessor347.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480)
at net.sourceforge.cobertura.coveragedata.CoverageDataContainer.readObject(CoverageDataContainer.java:373)
at sun.reflect.GeneratedMethodAccessor348.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at java.util.HashMap.readObject(HashMap.java:1030)
at sun.reflect.GeneratedMethodAccessor347.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 pom.xml 中使用此属性:
Use this property in your pom.xml :
您是否尝试过类似
export MAVEN_OPTS=-Xmx1024m
(或与您的机器匹配的最高值)?如果你仍然没有足够的内存来运行maven,那么我建议你尝试禁用其他插件并从测试覆盖范围中排除一些类,以检查是否确实是内存问题。
http://mojo.codehaus.org/cobertura-maven-plugin/usage。 html
编辑
其他想法:
设置以下属性(请参阅cobertura 插件属性)
尝试使用 fork 或通过以下方式增加内存。我不确定它是否适用于 cobertura,但似乎适用于 junit。此页面的片段:
或者
Did you try something like
export MAVEN_OPTS=-Xmx1024m
(Or the highest value that match your machine)?If you still don't have enough memory to run maven, then I would suggest you try to disable other plugin and exclude some classes from the test coverage to check if it's really a memory issue.
http://mojo.codehaus.org/cobertura-maven-plugin/usage.html
EDIT
Other ideas:
Set the following properties (see the cobertura plugin properties)
Try to use fork or increase the memory with the following. I'm not sure whether it works for cobertura, but seem to work for junit. Snippet from this page:
or