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

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

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

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


当前回答

错误:

对于“初始化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

其他回答

我得到了同样的错误,它得到解决时,我删除临时文件使用%temp%和重新启动eclipse。

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

有时它与

$ sysctl vm.overcommit_memory
vm.overcommit_memory = 2

如果你设置为:

$ sysctl vm.overcommit_memory=0

它应该会起作用。

我最近遇到了这个问题。我有3个java应用程序,起始堆大小为1024m或1280m。 Java查看交换中的可用空间,如果没有足够的可用内存,则jvm退出。

为了解决这个问题,我不得不终止几个分配了大量虚拟内存的程序。

我在x86-64 linux和64位jvm上运行。

我有适量的内存设置,但对我来说,它是使用64位intellij和32位jvm。一旦我切换到64位虚拟机,错误就消失了。