Compile Using Memory Allocation Enhancements
The Compiler Plugin accepts configurations for initial memory (meminitial
)
and maximum memory (maxmem
).
You can follow the example below to set the initial memory size to 128MB
and the maximum memory usage to 512MB:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>...</version>
<configuration>
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
Version 4 of the Maven compiler plugin additionally accepts the ‘k’, ‘M’ (upper-case) and ‘G’ suffixes for kilobytes, megabytes and gigabytes respectively.