Ahmed
Ahmed

Reputation: 109

Error: Could not create the Java Virtual Machine

I have visited all existing questions which are related to my question but I still have a problem. All installations are correctly installed. I am using the newest Netbeans version. After executing program I have this error:

Error: Could not create the Java Virtual Machine.
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: A fatal exception has occurred. Program will exit.

And my Netbeans.conf is:

# ${HOME} will be replaced by JVM user.home system property
netbeans_default_userdir="${HOME}/.netbeans/7.1.2"
# Options used by NetBeans launcher by default, can be overridden by explicit
# command line switches:
netbeans_default_options="-J-client -J-Xss2m -J-Xms16m -J-XX:PermSize=16m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true"
# Note that default -Xmx and -XX:MaxPermSize are selected for you automatically.
# You can find these values in var/log/messages.log file in your userdir.
# The automatically selected value can be overridden by specifying -J-Xmx or
# -J-XX:MaxPermSize= here or on the command line.
# If you specify the heap size (-Xmx) explicitly, you may also want to enable
# Concurrent Mark & Sweep garbage collector. In such case add the following
# options to the netbeans_default_options:
# -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled J-XX:+CMSPermGenSweepingEnabled
# (see http://wiki.netbeans.org/FaqGCPauses)
# Default location of JDK, can be overridden by using --jdkhome <dir>:
netbeans_jdkhome="C:\Arquivos de programas\Java\jdk1.7.0_07"
# Additional module clusters, using ${path.separator} (';' on Windows or ':' on Unix):
#netbeans_extraclusters="/absolute/path/to/cluster1:/absolute/path/to/cluster2"
# If you have some problems with detect of proxy settings, you may want to enable
# detect the proxy settings provided by JDK5 or higher.
# In such case add -J-Djava.net.useSystemProxies=true to the netbeans_default_options.

What do I have to do? I've been trying to resolve this error all day. My system Memory is 3Gb.

Upvotes: 10

Views: 77783

Answers (4)

SMAN
SMAN

Reputation: 31

We have couple of solutions for the above Problem

Solution 1: You can re-install the all components. ie it means you have install the entire s/w. for the Error: Could not create the Java Virtual Machine.

Solution 2: that maximum heap size varies based upon machine architecture e.g. 32 bit or 64 bit, JVM bit size e.g. 32 bit JVM or 64 bit JVM and operating system.

In 32 bit machine though theoretical limit of maximum heap size is 4GB, it varies on operating system to operating system e.g. on 32 bit windows XP maximum heap size limits upto 1.5G due to various reason while on 64 bit Solaris machine even with 32 bit JVM you can afford around 3.5GB. So when you run following java command in 32 bit Windows XP machine

Solution 3: One more worth noting syntax error while providing heap space is space between numeric literal and unit, as shown in below example:

Correct: ~/java java -Xmx1500 M
In-correct:   ~/java java -Xmx1500MB
In-Correct:  ~/java java -Xmx 1400M 

Upvotes: 2

Prashanth Shyamprasad
Prashanth Shyamprasad

Reputation: 837

I got the same error while starting Netbeans

Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

I try to restart Netbeans many times. Same error was repeating. Later I found it was happening as some other application is already using JVM. So I looked for such an application which was Tomcat Server. I terminated Tomcat and tried starting Netbeans again and it was fine. So try looking for any application that uses JVM.

Upvotes: 4

Miserable Variable
Miserable Variable

Reputation: 28752

Could not reserve enough space for object heap

This almost always means that your -Xmx is too high for the machine. There is a message above:

# Note that default -Xmx and -XX:MaxPermSize are selected for you automatically

Try to provide explicit value, start small. Note that -Xms must be less then or equal to -Xmx

Upvotes: 4

Anthony
Anthony

Reputation: 12736

-J-Xss2m -J-Xms16m -J-XX:PermSize=16m

Those are insufficient values. Try it increase from 16Mb to 512Mb (or 1Gb)

Upvotes: 1

Related Questions