I am developing a program to process PDF and SVG documents (a few Mbytes) and can run the application successfully on Eclipse (Windows) with a loop containing several documents. According to the Windows Task Manager it doesn't seem to grab more memory for each document and uses less than 1 GB. However on Maven it throws either OOME or GC overhead for the first document (typical surefire report, doesn't always fail in same place).
Tests run: 5, Failures: 0, Errors: 1, Skipped: 3, Time elapsed: 14.271 sec <<< FAILURE!
testPDFAnalyzerDIR(org.xmlcml.svg2xml.analyzer.PDFAnalyzerTest) Time elapsed: 14.259 sec <<< ERROR!
java.lang.OutOfMemoryError: Java heap space
at sun.nio.cs.UTF_8.newDecoder(UTF_8.java:49)
at java.lang.StringCoding$StringDecoder.<init>(StringCoding.java:116)
at java.lang.StringCoding$StringDecoder.<init>(StringCoding.java:108)
at java.lang.StringCoding.decode(StringCoding.java:167)
at java.lang.String.<init>(String.java:443)
at java.lang.String.<init>(String.java:515)
at nu.xom.Text.getValue(Unknown Source)
at org.xmlcml.graphics.svg.SVGElement.createSubclassedChildren(SVGElement.java:195)
I have read through a number of SO answers and I have set MAVEN_OPTS in the Windows environment variables
C:\Users\pm286\workspace\svg2xml-dev>echo %MAVEN_OPTS%
-Xmx2048m -XX:+UseGCOverheadLimit
Why does Eclipse not fail (it seems there is enough memory) and is there any further workaround for maven? I appreciate that I shall have to go looking for memory leaks and other inefficiencies but I'd like to get this phase through the tests for correct operation as opposed to performance. And is there any way I can get debug output from the program leading up to the surefire report so I can tell the immediate history?
Maven details:
C:\Users\pm286\workspace\svg2xml-dev>mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 17:31:09+0000)
Maven home: C:\Program Files\maven\bin\..
Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\java\jdk1.6.0_24\jre
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Eclipse:
Version: Indigo Release
Build id: 20110615-0604
Surefire usually runs in a own VM which does not use maven opts memory settings.
See here for how to adjust surefire memory settings: surefire plugin
So what you would have to do is to basically adapt your pom to set memory settings for the surefire plugin.
Since eclipse is usually doing things differently, I expect they run the tests without invoking a own VM or they use the memory settings in a different way.
OP addition: my pom now contains:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<argLine>-Xmx1024m </argLine>
</configuration>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With