Configure the Java Virtual machine memory size

Source: Internet
Author: User

Configure the Java Virtual machine memory size


The maximum memory that a Java virtual machine can use is limited, and the default value is usually 64MB or 128MB. If an application loads the data in memory to improve performance, such as exceeding the default maximum value of 128MB, it needs to increase the maximum memory available to the Java Virtual machine, otherwise an out-of-memory (out-of-system) exception will occur. When you start Java, you need to use the following two parameters:

-xms the size of memory used when initializing a Java virtual machine

-XMX maximum memory that a Java virtual machine can use

The size set in the above two parameters can be taken with a unit, for example: 256m for 256MB


Many of the underlying uses of Java virtual machines (such as TOMCAT) typically require the following configuration items to be configured:

java_opts= '-xms128m-xmx256m '

Use MyEclipse to run the main function to configure the virtual machine's memory through-XMS and-XMX:


Configuration method:

Right-click in the code editing area, run as---run configurations ..., select the second tab (i.e. arguments) in the pop-up window and enter the parameters to be passed in the VM arguments text box such as:-xms88m- Xmx128m, it's best to run it by clicking on Run;

If you want to configure the program's parameters, you need to enter the parameters to pass in the main method in the Programs Arguments text box, and then click Run below.

It is important to note that the main method parameter is an array, if more than one argument is required, the parameters are separated by a space, and any arguments are accessed in the main method by means of an array subscript.


Precautions:

The operating system and JDK need to match, such as 64-bit operating systems need to install 64-bit JDK to use the required memory size, or in jconsole, heap size, the maximum value is 120m.


Configure the Java Virtual machine memory size

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.