您的位置:首页 > 其它

“Invalid maximum heap size” when running Maven

2016-06-21 10:11 1301 查看
运行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.

方法三:

set MAVEN_OPTS=-Xmx512m -Xms128m -Xss2m
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: