In Window
1) Control Panel
2) System and Security
3) System
4) Advanced System settings
5) Click Advanced tab
6) Click Environment Variables…
7) From the user variable session click the new button
8) key in MAVEN_OPTS as variable name and
9) key in -Xmx512m as variable value
In Linux
From your terminal
export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"
In Maven
<project> [.. code omitted ..] <build> [.. code omitted ..] <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <fork>true</fork> <meminitial>128</meminitial> <maxmem>512m</maxmem> </configuration> </plugin> </plugins> [.. code omitted ..] </build> [.. code omitted ..] </project> Reference
Maven PermGen Space