每次我试图运行该程序时,都会重复得到以下异常。

虚拟机初始化时出错 无法为对象堆预留足够的空间 无法创建Java虚拟机。

我试图增加我的虚拟内存(页面大小)和RAM大小,但没有效果。

我怎样才能消除这个错误?


当前回答

我得到了同样的错误,并通过在run.conf.bat中配置它来解决这个问题

在Jboss5x中使用配置Run .conf.bat运行JVM

如果在传递语句时没有可用的空闲内存,请在run.conf.bat中进行更改

set "JAVA_OPTS=-Xms512m -Xmx512m -XX:MaxPermSize=256m"

其他回答

错误:

对于“初始化vm时发生错误,无法为对象堆jboss预留足够的空间”的错误。

根本原因:

JVM内存分配不当/不足,如下所述。 例如,jboss-eap-6.2\bin\standalone.conf中的JAVA_OPTS="-Xms1303m -Xmx1303m -XX:MaxPermSize=256m"或jboss-eap-6.2\bin\standalone.conf.bat中的"JAVA_OPTS=-Xms1G -Xmx1G -XX:MaxPermSize=256m",这只是JVM内存分配池参数。

解决方法:

Increase the heap size. To increase the heap size, goto -> jboss-eap-6.2\bin\standalone.conf.bat or jboss-eap-6.2\bin\standalone.conf change ->JAVA_OPTS="-Xms256m -Xmx512m -XX:MaxPermSize=256m" where -Xms is Minimum heap size and -Xmx is Maximum heap size. Usually its not recommanded to have same size for min and max. If you are running your application from eclipse, Double click on the server select 'open launch configuration' you will be redirected to the window 'Edit launch configuration properties'. In this windown goto the tab '(x)=Arguments'. In VM Arguments, define your heap size as mentioned below "-Dprogram.name=JBossTools: JBoss EAP 6.1+ Runtime Server" -server -Xms256m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true

在cassandra bin目录下的cassandra.bat文件中将-Xmx2G替换为-Xms512M或更大的内存。

有时它与

$ sysctl vm.overcommit_memory
vm.overcommit_memory = 2

如果你设置为:

$ sysctl vm.overcommit_memory=0

它应该会起作用。

使用-XX:MaxHeapSize=512m(或任何您需要的大数字)(或-Xmx512m简称)运行JVM

假设您有足够的空闲内存,并且正确地设置了JVM参数,那么您可能会遇到内存碎片的问题。在Windows XP上检查Java最大内存。