OutOfMemoryError and GC upper limit in maven but not eclipse

I am developing a program for processing PDF and SVG documents (several megabytes) and successfully launching the application on Eclipse (Windows) with a loop containing several documents. According to the Windows Task Manager, it does not seem to capture more memory for each document and uses less than 1 GB. However, on Maven, he throws either OOME or GC overhead for the first document (a typical assurance report does not always fail in one 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 read some SO answers and I set MAVEN_OPTS in windows environment variables

 C:\Users\pm286\workspace\svg2xml-dev>echo %MAVEN_OPTS% -Xmx2048m -XX:+UseGCOverheadLimit 

Why doesn't Eclipse work (seems to be enough memory), and is there any further solution for maven? I appreciate that I will have to look for memory leaks and other inefficiencies, but I would like this phase to go through tests for proper operation, not performance. And is there any way to get the debug output from the program leading to the surefire report so that I can tell you about the next story?

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 
+4
source share
1 answer

Surefire usually runs in its own virtual machine, which does not use maven's memory settings.

See here how to configure confident memory settings: confidence plugin

So what you need to do is basically adapt your pom to set the memory options for the surefire plugin.

Since eclipse usually does things differently, I expect them to run tests without invoking their own virtual machine or use the memory settings differently.

Adding OP: 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> 
+8
source

Source: https://habr.com/ru/post/1499758/


All Articles