Could not create the Java Virtual Machine on Ubuntu VPS with all the ram allocated to it

15,074

Memory allocation may be too small. try incrementing it a bit at a time. If it fails on the smaller one try the next larger allocation.

export _JAVA_OPTIONS="-Xms128m -Xmx128m
export _JAVA_OPTIONS="-Xms256m -Xmx256m
export _JAVA_OPTIONS="-Xms512m -Xmx512m
export _JAVA_OPTIONS="-Xms1024m -Xmx1024m

run this command after setting same:

java -jar yourJavaApp.jar

(you need to be within your app's directory).

Please note that you may try it "temporarily" by passing in as an option:

java -Xms128m -Xmx128m -jar yourJavaApp.jar 

It fails because the JRE doesn't have enough memory allocated. Perhaps you're running too many open apps, low on memory, etc.

Share:
15,074

Related videos on Youtube

Consumer
Author by

Consumer

Updated on September 18, 2022

Comments

  • Consumer
    Consumer over 1 year

    I'm trying to run a file on a vps with 384mb of ram, If I run the file with this command on terminal

    java -jar server.jar 
    

    It just starts the process but with only 180mb approx allocated to it, I need to allocate all the ram avaiable, if not the server will end crashing. I run the command free -m and I get this output:

                     total       used       free     shared    buffers     cached
    Mem:           384         58        325          6          0         44
    -/+ buffers/cache:         14        369
    Swap:           96          0         96
    

    So I've tried lots of commands with different amounts of ram like those but no one worked, java could not create the java virtual machine:

    java -Xms32M -Xmx256M -jar minecraft_server.jar
    

    I tried putting the maximum ram, half and changing values but it gives error. Before I was running the same file on a 1GB vps and that command was working fine:

    java -Xmx1024M -Xms1024M -jar bukkit.jar
    

    My java version is:

        java version "1.7.0_55"
    OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)
    OpenJDK Client VM (build 24.51-b03, mixed mode)
    

    My OS is Ubuntu Server 12.04 x86 Hope you can help me, I'm stuck with the same problem two days

    EDIT: Error messages with different amounts of ram

        root@vps-dot-me:~# java -Xms32M -Xmx384M -jar mine.jar
    Error occurred during initialization of VM
    Could not reserve enough space for object heap
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    
    root@vps-dot-me:~# java -server -Xms128M -Xmx256M -jar mine.jar
    Error occurred during initialization of VM
    Could not reserve enough space for object heap
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    
        root@vps-dot-me:~# java -XX:MaxHeapSize=256m -jar mine.jar
    Error occurred during initialization of VM
    Could not reserve enough space for object heap
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    
    • Daniel B
      Daniel B almost 10 years
      So, what’s the error message?
    • Consumer
      Consumer almost 10 years
      Edited with error messages