0

My program works well with small file input but when I read a file with around 2 GB I got an exception due to heap size space. Indeed, my pom.xml file is:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.example</groupId>
  <artifactId>rdf4j-getting-started</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>HelloRDF4J</name>
  <dependencies>
    <dependency>
        <groupId>org.eclipse.rdf4j</groupId>
        <artifactId>rdf4j-runtime</artifactId>
        <version>2.0M2</version>
    </dependency>
     </dependencies>
  <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <encoding>utf8</encoding>
            </configuration>
        </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>Convert</mainClass>

                     <arguments>
                        <!--<argument>argument1</argument>-->
                    </arguments>
                </configuration>
            </plugin>

            <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19</version>
        <configuration>
            <argLine>-Xmx1024m</argLine>
        </configuration>
      </plugin>
    </plugins>
</build>
</project>

Got the following exception:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project rdf4j-getting-started: An exception occured while executing the Java class. null: InvocationTargetException: Java heap space -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Gayan Mettananda
  • 1,498
  • 14
  • 21
bib
  • 944
  • 3
  • 15
  • 32
  • Possible duplicate of [What happens when there's insufficient memory to throw an OutOfMemoryError?](https://stackoverflow.com/questions/9261705/what-happens-when-theres-insufficient-memory-to-throw-an-outofmemoryerror) – talex Dec 06 '18 at 04:18
  • Problem is with exec plugin execution and not with surefire plugin. – Himanshu Bhardwaj Dec 06 '18 at 04:39
  • 1
    Possible duplicate of [mvn java:exec with increased memory](https://stackoverflow.com/questions/21468425/mvn-javaexec-with-increased-memory) – Himanshu Bhardwaj Dec 06 '18 at 04:40
  • @HimanshuBhardwaj i tried export MAVEN_OPTS="-Xmx10240M" but still not working. same exception is generated. Does i need to change any thing inmy pom.xml? – bib Dec 06 '18 at 04:52
  • Can you do an `echo $MAVEN_OPTS` or `echo %MAVEN_OPTS%` on the **same console** from which you are running the commands. Also change `M` to `m`. No changes in pom.xml required. Also you can run with mvn -X , this will generate a lot of useful logs to debug the problem. – Himanshu Bhardwaj Dec 06 '18 at 04:55
  • @HimanshuBhardwaj: echo MAVEN_OPTS prints empty string (nothing is obtained) – bib Dec 06 '18 at 05:57
  • That means the settings will also not be applied. I suppose you have set that as a Environment Variable. Then just open a new console and try to echo if it still doesn't work, then list the steps you have done to set that variable. – Himanshu Bhardwaj Dec 06 '18 at 06:53
  • @HimanshuBhardwaj, now i type before running the mvn command, export export MAVEN_OPTS="-Xmx10240M" and then echo $MAVEN_OPTS. im working on a linux server. – bib Dec 06 '18 at 16:52
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/184830/discussion-between-bib-and-himanshu-bhardwaj). – bib Dec 06 '18 at 17:11

0 Answers0