简体   繁体   中英

Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine

I am facing this problem since more than a month, here is what I see when I run java on command line:

$ java -Xmx1300m 
Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine.

If I run with less memory it works fine

$ java -Xmx1240m Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file) ..... .....

I spent a week trying to debug this and nothing worked. Finally I had my IT support guys replace the laptop. This happened a month ago on 10/23. Now, after a month, the same problem is back on my new system.

My system configuration is:

Win 7 Enterprise (64-bit), Service Pack 1. Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz 8.00 GB RAM

Java: java version "1.5.0_20" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_20-b02) Java HotSpot(TM) Client VM (build 1.5.0_20-b02, mixed mode)

We are a team of about 30 guys here and I am the only one facing this. All others have almost the same config and working fine for them.

An important observation is Java works fine for some time and then this problem appears once it appears it doesn't go away, even if I re-install java.

I faced this issue the 3rd time after the IT support guys re-imaged by laptop. It worked for a month and now the same problem is back.

Everybody is completely clueless. I have started using 2 laptops now. :-)

Anyway, here is how to fix it:

Go to Start->Control Panel->System->Advanced(tab)->Environment Variables->System Variables->New:

Variable name: _JAVA_OPTIONS

Variable value: -Xmx512M

taken from this link

Eureka ! Finally I found a solution on this.

This is caused by Windows update that stops any 32-bit processes from consuming more than 1200 MB on a 64-bit machine. The only way you can repair this is by using the System Restore option on Win 7.

Start >> All Programs >> Accessories >> System Tools >> System Restore.

And then restore to a date on which your Java worked fine. This worked for me. What is surprising here is Windows still pushes system updates under the name of "Critical Updates" even when you disable all windows updates. ^& %)# * Windows :-)

This might also occur if you are running on 64-bit Machine with 32-bit JVM (JDK), switch it to 64-bit JVM. Check your (Right Click on My Computer --> Properties) Control Panel\\System and Security\\System --> Advanced System Settings -->Advanced Tab--> Environment Variables --> JAVA_HOME...

谢谢。我将堆空间从 2000MB 更改为 1024MB 并且它起作用了...

I've just seen this problem myself, Jboss AS7 with jdk1.5.0_09. Update System Property JAVA_HOME to jdk1.7+ to fix (I'm using jdk1.7.0_67).

If your computer is a 64bit, all you need to do is uninstall your Java x86 version and install a 64bit version. I had the same problem and this worked. Nothing further needs to be done.

您可以在 _JAVA_OPTIONS 中更新用户路径:-Xmx512M 路径:C:\\Program Files (x86)\\Java\\jdk1.8.0_231\\bin;C:\\Program Files(x86)\\Java\\jdk1.8.0_231\\jre \\bin 现在它正在工作 //

Sometimes it may happen that you run multiple applications on the same java VM. In Case you have tried all the other solutions described above and it didnt work. Try Running your process by running it on a newly created java VM by passing vmargs

-agentlib:jdwp=transport=dt_socket,server=y,address=10049,suspend=n . 

Here address is what the vm takes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM