Error: Could not create the Java Virtual Machine

73,549

Solution 1

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

Solution 2

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.

Solution 3

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 

Solution 4

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

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

Share:
73,549
Ahmed
Author by

Ahmed

Updated on July 09, 2022

Comments

  • Ahmed
    Ahmed almost 2 years

    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.

  • Ahmed
    Ahmed over 11 years
    i have checked by different values but same
  • Alfabravo
    Alfabravo over 11 years
    Which values have you tried? The thing is: you must give it more space or it won't start properly. Also, the starting value shouldn't be too big, but the max value must be big enough. Try as the answer says: change -J-Xms16m to -J-Xms80m and -J-XX:PermSize=16m to -J-XX:PermSize=80m, then add -J-Xmx512m and -J-XX:maxPermSize=512m (or even 1024m)
  • Ahmed
    Ahmed over 11 years
    i used 2m till 1024m same error, May it any Netbeans problem or SDK
  • Anthony
    Anthony over 11 years
    that means 512 bytes, 1024 bytes and 256 bytes
  • Ahmed
    Ahmed over 11 years
    512m,1024m, and 256m i use like this and also small values like 2m 8m 10m still problem
  • veer7
    veer7 over 10 years
    +1 for specifying Correct and In-correct ways of specifying -Xmx option. Sometimes this becomes big gotcha.