2

If I am building a projecting using:

mvn install

I see the following:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:


The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: PermGen space

I'm not sure where I would be updating my java options?

I'm running this on ubuntu.

codecompleting
  • 9,251
  • 13
  • 61
  • 102
  • 1
    possible duplicate of [java.lang.OutOfMemoryError: PermGen space](http://stackoverflow.com/questions/3101128/java-lang-outofmemoryerror-permgen-space) – Brian Roach Jan 27 '12 at 17:21
  • Duplicate: http://stackoverflow.com/questions/2210005/config-maven-2-to-print-out-javac-commands-during-compile-phase – Amir Afghani Jan 27 '12 at 17:23

2 Answers2

7

If you don't like to be dependent on somebody's environment you may specify to fork compiler plugin and allocate enough memory to it.

I suggest you actually do this in the <pluginManagment> section of your parent POM project

<build>
  ...
  <pluginManagment>
    ...
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.3.2</version>
      <configuration>
        ...

        <!-- Memory management -->
        <fork>true</fork>
        <meminitial>128m</meminitial>
        <maxmem>512m</maxmem>

        ...
      </configuration>
    </plugin>
    ...
  </pluginManagment>
  ...
</build>
Alexander Pogrebnyak
  • 44,836
  • 10
  • 105
  • 121
  • so this fires up a new jvm as oppose to using the one the os uses by default? – codecompleting Jan 30 '12 at 21:36
  • For future generations, you want to do exactly this. It makes it far easier to on board smoothly because a git clone setups the maven environment without have to touch the PC. It also keeps the configurations easily accessible when trouble shooting the build (pom is the first place to look after the stacktrace, so, technically the second place to look). – Virmundi Jan 16 '14 at 14:02
4

Tweak your maven options. Generally this is set in /etc/mavenrc, ${HOME}/.mavenrc, or your Windows environmental properties dialog box.

export MAVEN_OPTS="-Xmx512M -XX:MaxPermSize=512M" 

has worked for some, you might need to bump the numbers up (depending on your circumstance)

The first option "-Xmx512M" configures maximum memory, while the second option "-XX:MaxPermSize=512M" allows PermGen space to grow as large as (in this case) the maximum memory.

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138
  • Down voted because, while it works, it will put any projects that follow this advice at risk when moving between PCs. – Virmundi Jan 16 '14 at 14:03