Problem scenario
You are getting an error such as “java.lang.OutOfMemoryError java heap space”
You have plenty of swap space available, but this error persists. The problem is as if nothing is using swap space you know exists. Why won’t your Java program or Maven build utilize the swap space that is available to it?
Possible solution #1 (for Maven builds)
Run a command like one of these (but uncomment the second one if you want to commit roughly 5 GB of memory to the maven build):
export MAVEN_OPTS=-Xmx512m
# export MAVEN_OPTS=-Xmx5120m
Now retry your mvn command.
…