Tuning the JVM parameters for JDK and Tomcat under eclipse

Source: Internet
Author: User
Tags xms

Under Eclipse debugging and running, there are often adjustments java.lang.OutOfMemoryError:Java heap space

The reason I guess is the use of MAVEN,SUBVERSION,MYLAR,WTP and other plug-ins, there is a large file, the operation of the object caused, the specific reason is still uncertain.

Find the relevant information on the Internet, found a solution: Method (1) After the operation did not work, but you can refer to the technique of viewing memory. Specific solutions See methods (2), (3)

First, in the Eclipse root directory, locate Eclipse.ini, where you specify the initial heap
Size and maximum heap size:
-xms 64M
-xmx
256M
Where-xms is the initial heap size,-XMX is the maximum heap
Size

During the actual use, I found that when I started eclipse, the heap
Size is about 40m, and it can reach 128m, so my settings are
-xms
64m
-xmx 128m
For PermGen space:
Specify the parameters in Eclipse.ini:
-permsize
256m
-maxpermsize
784m

Second, modify the JDK to use memory (this method is feasible)

Locate the window->preferences->java->installed JRE in the Eclispe and click Edit on the right
button, in the edit interface, in the "Default VM Arguments" option, fill in the following values.

-xms64m-xmx128m

Third, modify the run configurations (this method is feasible)

Right-click on the code, then "Run as", then "Run Configurations", in the arguments parameter "VM arguments:
Fill in the following values.

-xms64m-xmx128m

Iv. querying current JVM memory code

The following is the code that queries the current JVM's memory size and can test whether the JVM's memory changes after the above settings. No need to restart eclipse after adding configuration items for JVM memory
。 The specific code is as follows:

public class Testmemory {
public static void Main (string[] args) {

System. Out. println ("Memory Information:" + tomemoryinfo ());

}

public static String Tomemoryinfo () {

Runtime currruntime = Runtime.getruntime ();

int nfreememory = (int) (Currruntime.freememory ()/1024/
1024);

int ntotalmemory = (int) (Currruntime.totalmemory ()/1024/
1024);

return nfreememory + "m/" + ntotalmemory + "M (free/total)";

}
}

You can also publish the project as a war package to a tomcat that exists in the management console Host-manager. Go to the console and select status to view memory usage.

Set up, the actual running results can be viewed through the "Configuration Details" button in Eclipse "Help"-the "About Eclipse SDK" window. There is also a way to see the allocation and usage of the current heap size in eclipse, and to enforce garbage collection.
Right-click on the eclipse shortcut and add parameters to the target bar:
-debug
Options-vm
Javaw.exe
Then, under the Eclipse root directory, create a new file named options, without the suffix name. Add content to this file:
Org.eclipse.ui/perf/showheapstatus=true
Restart Eclipse to see the current heap in the lower-left corner of Eclipse
Size usage and distribution, you can also manually perform garbage collection, see the heap size is not enough to come once.

Tuning the JVM parameters for JDK and Tomcat under eclipse

Related Article

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.