martes, 8 de enero de 2013

Out of Memory with Maven & MAVEN_OPTS

Have you ever got an error like this:


java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2786)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
at java.util.jar.JarVerifier.update(JarVerifier.java:194)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:322)
at java.util.jar.JarFile.getInputStream(JarFile.java:388)
at sun.misc.URLClassPath$JarLoader$2.getInputStream(URLClassPath.java:69


Well this is the easy solution, increase the memory of the JVM.

BUT HOW IF I'M BUILDING WITH MAVEN???

God question, and the answer is:

export MAVEN_OPTS=-Xmx512m


Of course this will follow the same rules as for the vm arguments for the JVM, so please modify your memory limit accordingly.

Also this export command, for you Mac users, will only set the env var for the current terminal not for all the future ones.

Hope you find this useful I know I'll keep coming back to this post just to remember this.


No hay comentarios:

Publicar un comentario