Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Mastering Apache Maven 3
  • Table Of Contents Toc
  • Feedback & Rating feedback
Mastering Apache Maven 3

Mastering Apache Maven 3

By : Siriwardena
4.3 (3)
close
close
Mastering Apache Maven 3

Mastering Apache Maven 3

4.3 (3)
By: Siriwardena

Overview of this book

If you are working with Java or Java EE projects and you want to take full advantage of Maven in designing, executing, and maintaining your build system for optimal developer productivity, then this book is ideal for you. You should be well versed with Maven and its basic functionality if you wish to get the most out of the book.
Table of Contents (11 chapters)
close
close
10
Index

Configuring the heap size

Once you have installed Maven in your system, the next step is to fine-tune it for optimal performance. By default, the maximum heap allocation is 256 - 512 MB (-Xms256m to -Xmx512m). This default limit does not work while building a large, complex Java project, and it is recommended that you have at least 1024 MB of maximum heap. If you encounter the java.lang.OutOfMemoryError error at any point during a Maven build, it is mostly due to the lack of memory. You can use the MAVEN_OPTS environment variable to set the maximum allowed heap size for Maven at a global level.

The following command will set the heap size in Linux. Make sure that the value set as the maximum heap size does not exceed your system memory of the machine that runs Maven.

$ export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m"

If you are on Microsoft Windows, use the following command:

$ set MAVEN_OPTS=-Xmx1024m -XX:MaxPermSize=128m

Here -Xmx takes the maximum heap size and -XX:MaxPermSize takes the maximum PermGen size.

Note

Maven runs as a Java process on JVM. As Java proceeds with a build, it keeps on creating Java objects. These objects are stored in the memory allocated to Maven. This area of memory where Java objects are stored is known as heap. Heap is created at the JVM start, and it increases as more and more objects are created up to the defined maximum limit. The -Xms JVM flag is used to instruct JVM the minimum value it should set at the time it creates the heap. The -Xmx JVM flag sets the maximum heap size.

Permanent Generation (PermGen) is an area of memory managed by JVM, which stores the internal representations of Java classes. The maximum size of PermGen can be set by the -XX:MaxPermSize JVM flag.

To learn about the Maven OutOfMemoryError error, check out the information at this link: https://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryError.

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete