2
votes

I get the following error running the maven build for Apache Sling, even with the recommended heap size:

main:
     [echo] **************** WARNING (SLING-443/SLING-1782) ******************************
     [echo] On most platforms, you'll get OutOfMemoryErrors when building unless you set
     [echo] on 32bit platforms: MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=256M", see SLING-443
     [echo] on 64bit platforms: MAVEN_OPTS="-Xmx512M -XX:MaxPermSize=512M", see SLING-1782
     [echo] ******************************************************************************
[INFO] Executed tasks
[INFO] 
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ sling-launchpad-webapp-archetype ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/thomasf/slingDownload/sling/maven/archetypes/launchpad-webapp/src/test/resources
[INFO] Copying 3 resources
[INFO] 
[INFO] --- animal-sniffer-maven-plugin:1.7:check (default) @ sling-launchpad-webapp-archetype ---
[INFO] Checking unresolved references to org.codehaus.mojo.signature:java15:1.0
[ERROR] Java heap space -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryError

Sure enough my heap size is the same that they recommend on the project homepage:

echo $MAVEN_OPTS
-Xmx512M -XX:MaxPermSize=512m

I suspect that the cause is that maven is forking and the jvm in the child process does not have the same heap size - however I cannot identify which plugin is forking from the console output.

Any ideas appreciated !!! Thanks

3

3 Answers

0
votes

You can try to just increase the memory:

MAVEN_OPTS=-Xmx1024M -XX:MaxPermSize=512m

or set it using JAVA_OPTS (but this affects any JVM process for the executing user!) so the child process will have these settings as well:

JAVA_OPTS=-Xmx512M -XX:MaxPermSize=512m

try to increase the memory with MAVEN_OPTS first.

regards

werner

0
votes

You can check in Environment Variables of your Computer, if MAVEN_OPTS variable is declared or not. If not Declare it as

MAVEN_OPTS=-Xmx1024M -XX:MaxPermSize=512m

else if, its already declared, just increase the Memory size.

This way it worked for me.

0
votes

Even if You use the JAVA_OPTS environment variable there is not enough memory? Since this affects any running vm a newly spawned process should have these settings too.

Or try using 1200M of memory? Maybee there is not much heap memory missing, if you run 64 bit JVM you may just need more... interesting question.

I would run the build using -X and maybe its a plugin / goal that executes prior to the heap error. Hopefully that plugin can be configured.