Java Virtual machine is out of memory, "Could not create the Java VM" problem solution

Source: Internet
Author: User
Tags xms

"Could not create the Java Virtual machine" encountered a problem while running Java programs. As follows:

The reason is that the Java heap is running out of memory to run the JVM and requires additional memory.

Searching for this problem on the Internet is mostly a workaround for a program that modifies the JVM's memory, such as Eclipse, and so on. What if there are problems with other programs?

Now give a global Java virtual machine a way to modify memory. In WIN Xp,win 7,win8 all can.

Solution: Add a System environment variable

Variable name: _java_options

Variable Value:-xmx512m

Once saved, it ok!!

Here is a description of the Java heap memory, which is a translation of an English web page.

About Java Heap Memory:

JAVA-XMX is the configuration parameter to control the amount of memory in Java uses on a system. Basically these settings is there to control the Heap memory size of Java. There is settings related to Java heap memory:

    • -xmx to set the maximum heap memory size
    • -XMS to set the minimum heap memory size

Tips to set the Java heap memory size

Managing the Java heap memory size for a server are very crucial as the whole performance depends on this memory size, off Course there is other factors which affects the performance. So let's see how can set these parameters to control the Java heap memory size.

Do not set-xmx to too small value  

If you set-xmx too small for your servers then your application could not work properly and you could get out of memory except Ion. So never set this too small as this is the maximum amount of memory you are allocating for Java and it cannot utilize memo Ry beyond the set value.

It was always advisable to set-xmx to a higher value if you had enough memory space available on your server. On the other hand if you set-xmx value to a higher value your other resources would not be able to perform well as you hav E already reserved some of your memory for Java. So before setting the maximum heap size memory just check how much memory are free. To does, stop your application server and check the free memory and accordingly you can set the maximum memory size. For example if you had 512M free memory then you can set the heap memory to 300M safely i.e.-xmx300m.

Set-xms to a small value

If you set-xms to higher the value of might run out of memory. So always try to keep it to a small value like-xms16m. In Tomcat if you restart the server it starts a Java process and that process takes the SAME-XMS as the default value F The or the Tomcat and if it is higher-get out of memory.

Now let's see how to set Java heap memory in different servers.

How to set Java heap size in Tomcat

To set the Java heap size in Tomcat you need to edit the catalina.sh (on Linux) or Catalina.bat (on Windows) file. You can find these files inside the bin directory of Tomcat. Open the appropriate file and search for catalina_opts and set the value as shown below, you can change the max and Min va Lue to whatever you want.

Set catalina_opts=-xms64m-xmx512m

Export catalina_opts= "-xms64m-xmx512m"

setenv catalina_opts "-xms64m-xmx512m"

The approximate translation is as follows:

The JAVA-XMX configuration parameter controls the amount of memory used on the Java system. Basically these settings have control over the size of the Java heap memory. There are two kinds of settings related to Java heap memory:

    • -Xmx Set the maximum heap memory size
    • XMS sets the minimum heap memory size
Recommended setting Java heap memory size

The Management Server's Java heap memory size is very important for the overall performance depends on this memory size, and of course there are other factors that affect performance. So let's see if you can set these parameters to control the Java heap memory size.

do not set-xmx too small value  

If you set up for your server-xmx is too small, then your application may not work properly and you may get an out of memory exception. So do not set too small, because this is your maximum memory allocation for Java and it cannot utilize memory beyond the set value.

It's always wise-xmx higher value if you have enough memory space available on the server. On the other hand if you-Xmx value is set to a higher value other resources will not be able to execute as well as you have reserved some of your Java memory. So it is free to check how much memory is available before setting the maximum heap size of memory. To do this, stop the application server and check for free memory, so you can set the maximum memory size. For example, if you have 512 free memory, then you can set up heap memory 300 security that is-xmx300m.

XMS is set to a smaller value

If you set the XMS higher value it may run out of memory. So always try to keep it like-xms16m a smaller value. In Tomcat when you restart the server and start a Java process, the process requires the same XMS tomcat default value, and if it is higher you may lose memory.

Now let's look at how to set the Java heap memory on different servers.

How to set the Tomcat Java heap size

Set Java heap size in Tomcat you need to edit catalina.sh (on Linux) or Catalina. Bats (on Windows) files. You can find these files in the Tomcat bin directory. Open the appropriate file and search catalina_opts and set the values as shown below, you can change any of the maximum and minimum values you want.

Set catalina_opts =-xms64m-xmx512m

Export catalina_opts = "-xms64m-xmx512m"

setenv catalina_opts "-xms64m-xmx512m"

Java Virtual machine is out of memory, "Could not create the Java VM" problem solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.