“Invalid maximum heap size” when running Maven
Posted Ido
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了“Invalid maximum heap size” when running Maven相关的知识,希望对你有一定的参考价值。
运行mvn package,报错:
Invalid maximum heap size: -Xmx512m.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
解决方法一:
alter jvm.config in .mvn directory ( it is in controller directory ). study mvn.sh that comes with maven. you will see MAVEN_OPTS setting in the script. try out java -version before altering. eg : java -Xmx512m -version now you know how to go about and make the changes.
解决方法二:
you can try to set the initial heap size and initial permgen size relatively small, but set the proper max heap and pergent via -Xms128m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m
Also don‘t set permgen to 512 - it‘s too much for typical scenarious.
Also you may want to use fork option with maven and start plugin execution in different JVMs at all.
For example
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
Also, while allocating memory also make sure that you have that much free memory available.
以上是关于“Invalid maximum heap size” when running Maven的主要内容,如果未能解决你的问题,请参考以下文章