Eclipse Memory Overflow

Source: Internet
Author: User
Tags xms

February 22, 2011 Tuesday 11:14

eclipse.exe-vmargs-xms128m-xmx512m-xx:permsize=64m-xx:maxpermsize=128m

The Eclipse.ini configuration below the eclipse root directory searched for some information from the Internet.

-vmargs: Description follows the parameters of the VM
-xms128m: Virtual machine occupies the minimum memory of the system
-XMX512M: 5% of the maximum memory for a virtual machine occupancy system is 25.6M, and the value of-XMX is theoretically required with-xx:maxpermsize
Must be greater than 25.6M
-xx:permsize: Minimum heap size. Generally reported that the memory is not enough, it is said that this is too small,
The remainder of the heap space is less than 5% warning, it is recommended to set this slightly
Larger, but depending on the size of your machine's memory to set
-xx:maxpermsize: Maximum heap size. This one's a little bigger.

Change the parameters inside to
-vmargs
-xms128m
-xmx512m
-xx:permsize=128m
-xx:maxpermsize=256m
Problem Solving!

From the information on the Internet to see permsize bigger is certainly better, and preferably set permsize and MaxPermSize as big. The reasons are as follows:
PermSize and MaxPermSize if set to the same can also improve performance to some extent, because permsize will need to transfer the data in the constant changes. If it is fixed, you can reduce the performance penalty for each expansion of the permsize.

1, PermGen space Introduction

PermGen space is the full name of permanent Generation space, refers to the memory of the permanent storage area Outofmemoryerror:permgen space from the surface is the memory benefits, the solution must be to increase memory.

Tell me why memory benefits:
(1) This section is used to store class and meta information, which is placed in the PermGen space area when loaded, and is different from the heap area where the instance is stored.
(2) GC (garbage Collection) does not clean up permgen space during the main program run time, so if your app will load many classes, PermGen space error is likely to occur. This error is common when the Web server pre-compile the JSP.

If you have a large number of third-party jars under your web app that are larger than the JVM's default size (4M), this error message will be generated.

Workaround: Manually set the MaxPermSize size

To modify the Tomcat_home/bin/catalina.bat, add the following line above the echo "Using catalina_base: $CATALINA _base":
Java_opts= "-server-xx:permsize=64m-xx:maxpermsize=128m
  Recommendation: Move the same third-party jar files to the Tomcat/shared/lib directory, which reduces the memory consumption of the jar document

1. Meaning of the parameter

-vmargs-xms128m-xmx512m-xx:permsize=64m-xx:maxpermsize=128m

The-vmargs in the

parameter means that the JVM parameters are set, so the following are all the parameters of the JVM, and we'll first look at the mechanism of the JVM's memory management, and then explain what each parameter means.
Heap and non-heap (non-heap) memory
Officially, "Java virtual machines have a heap, which is a runtime data region where all class instances and arrays of memory are allocated." The heap is created when the Java virtual machine is started. "" The memory outside the heap in the JVM is called non-heap (non-heap memory) ". You can see that the JVM primarily manages two types of memory: heap and non-heap. In a nutshell, a heap is a Java code-readable memory that is left to the developer, not a heap, which is left to itself by the JVM, so the method area, the JVM internally processes or optimizes the required memory (such as the JIT-compiled code cache), each class structure (such as running a constant pool, field, and method data) And the code for methods and construction methods are in non-heap memory. &NBSP
Heap memory allocation
the initial allocated memory of the JVM is specified by-xms , which defaults to the 1/64 of the physical memory; JVM's maximum allocated memory is specified by-xmx , The default is 1/4 of physical memory. When the default free heap memory is less than 40%, the JVM increases the heap until the maximum limit of-xmx, and when the free heap memory is greater than 70%, the JVM reduces the heap until the minimum limit of-XMS. So the server generally sets-xms,-xmx equal to avoid resizing the heap after each GC.  
Non-heap memory allocation
The JVM uses-xx:permsize to set the non-heap memory initial value , which defaults to the 1/64 of physical memory; by XX: MaxPermSize sets the maximum non-heap memory size of , which is 1/4 of physical memory by default.  
JVM memory Limit (max.)
First, the JVM memory is limited to the actual maximum physical memory, assuming that the maximum amount of physical memory is large, the JVM memory Max is related to the operating system. In short, the 32-bit processor, although the controllable memory space has 4GB, but the specific operating system will give a limit, This limit is generally 2GB-3GB (typically under Windows systems for the 1.5g-2g,linux system 2g-3g), and processors over 64bit are not limited.

2. Why do some machines I set-xmx and-xx:maxpermsize to 512M after eclipse can be started, and some machines will not boot?

We have learned from the above introduction to JVM memory management that there are two types of JVM memory: heap memory and non-heap memory, and the JVM's maximum memory depends first on actual physical memory and operating system. So there are several reasons why setting a VM parameter causes the program to fail to start:
1) The value of-XMS in the parameter is greater than-XMX, or the value of-xx:permsize is greater than-xx:maxpermsize;
2) The sum of-XMX values and-xx:maxpermsize exceeds the maximum limit of JVM memory, such as the maximum memory limit of the current operating system, or actual physical memory, and so on. When it comes to physical memory, it is important to note that if your memory is 1024MB, the actual system is not likely to be 1024MB, because a portion of it is consumed by the hardware.

3. Why write the above parameters to the Eclipse.ini file eclipse does not perform the corresponding settings?
Why is the same argument valid on a shortcut or command line and is not valid in the Eclipse.ini file? This is because we do not comply with the Eclipse.ini file setting rules:
parameter shape such as "Item Value" In this form, there are spaces in the middle of the need to write a newline, if the value of a space in the need to be enclosed in double quotation marks. For example, we use the-VM C:\Java\jre1.6.0\bin\javaw.exe parameter to set up the virtual machine, in the Eclipse.ini file to write this:
-vm 
C:\Java\jre1.6.0\bin\ javaw.exe 
According to the above, the last parameter can be written in Eclipse.ini:
-vmargs 
-xms128m 
-xmx512m 
-XX:PERMSIZE=64M&NBSP
-xx:maxpermsize=128m 
The results of the actual operation can be obtained through the "help" in Eclipse-"about the Eclipse SDK" window. Configuration Details button to view it.
It is also necessary to note that the contents of the Eclipse.ini file included in the Eclipse compression package are as follows:
-showsplash 
org.eclipse.platform 
-- Launcher. xxmaxpermsize 
256m 
-vmargs 
-xms40m 
-xmx256m 
where –launcher. Xxmaxpermsize (Note that the first is two connectors) the meaning of the -xx:maxpermsize parameter is basically the same, I think the only difference is that the former is the parameter set when the Eclipse.exe is started, and the latter is the parameter in the JVM used by Eclipse. In fact, the two set a can, so here can put –launcher. Xxmaxpermsize and Next line use # comment out.

3. Other start-up parameters. If you have a dual-core CPU, you might be able to try this parameter:

-xx:+useparallelgc

Allows the GC to execute faster. (only new parameters added to the GC in JDK 5)

Add:

You can add server-initiated JVM parameter settings by selecting the appropriate server, such as Tomcat5, in Myelipse to expand the JDK subkey page on the inside:

-xms128m
-xmx256m
-xx:permsize=128m
-xx:maxnewsize=256m
-xx:maxpermsize=256m

Eclipse Memory Overflow

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.