Java heap space, PermGen space error using JVISUALVM monitoring set a reasonable value

Source: Internet
Author: User

Use MyEclipse to start Tomcat report Java heap space, PermGen space error, heap memory is insufficient, PermGen memory is low
Need to increase Tomcat boot key parameters Xmx and Xx:maxpermsize
PermGen is a permanent area of memory that holds the class and method objects, as well as the string object
(Sun Original: Permanent generation is the area of the heap where class and method objects are stored. If an application loads a very large number of classes and then the size of the permanent generation might need to be increas Ed using the-xx:maxpermsize option.

Interned java.lang.String objects is also stored in the permanent generation. The Java.lang.String class maintains a pool of strings. When the Intern method was invoked, the method checks the pool to see if a equal string is already in the pool. If there is and then the Intern method returns it; Otherwise it adds the string to the pool. In more precise terms, the Java.lang.String.intern method was used to obtain the canonical representation of the String; The result is a reference to the same class instance that would being returned if that string appeared as a literal. If an application interns a huge number of strings, the permanent generation might need to being increased from its default s Etting. When this kind of error occurs, the text String.intern or Classloader.defineclass might appear near the top of the stack T Race is printed. The Jmap-permgen command prints statistics for the objects of the permanent generation, including information about Inter Nalized String instances. See 2.6.4 Getting information on the Permanent Generation.


PermGen is also a special memory area: Classloader loaded East is not recyclable, they are placed in the PermGen
(Tomcat Original: Why does the memory usage increase when I redeploy a Web application? Because the Classloader (and the Class objects it loaded) cannot be recycled. They is stored in the permanent heap generation by the JVM, and if you redepoy a new class loader is created, which LOA DS Another copy of all these classes. This can cause oufofmemoryerrors eventually.)

Back to my question come on, open%java_home%bin\jvisualvm.exe (jdk6 above there)
To view Tomcat's memory situation, click the Tomcat tab under Monitor, and when used heap = max heap used PermGen = Max PermGen, Tomcat is still in the boot, and an error will be found;
Since the SERVER->TOMCAT->TOMCATX.X->JDK parameter in MyEclipse has been set to-xms64m-xmx512m-xx:maxpermsize=80m
But the Max heap in the monitor screen is 256M
Click on the Overview tab and find the JVM parameters as follows:
-xms64m
-xmx512m
-xx:maxpermsize=80m
-xms64m
-xmx256m

It is clear that Tomcat used the final settings-xms64m-xmx256m; this is the VM boot parameter in MyEclipse's properties-"java->installed JREs", double-click the default enabled JRE, remove the parameters or set to-xms64m -xmx512m
Go back to SERVER->TOMCAT->TOMCATX.X->JDK and change-xx:maxpermsize=80m to-xx:maxpermsize=128m.
Save and then start Tomcat,ok

In addition, continuous monitoring of Tomcat memory using JVISUALVM found that the memory usage of the heap area was reduced steadily after a peak and the memory was recycled;
While the memory of the PermGen region is increasing to a peak, it no longer increases, but then the memory of this area is not recycled, verifying the above statement;

Two more words: The dynamic loading of Java derived from a number of frameworks, in the space also exposed problems, reflection in time also has an efficiency problem: The following is a group of test data:

Java version 1.6.0_13
Java HotSpot (TM) Client VMS
11.3-b02
Sun Microsystems INC.

Direct Access using member field:
47 125 47) 46 46
Average time = Ms.
Reference access to member field:
109 109 110) 94 109
Average Time = 106 Ms.
Reflection access to member field:
13094 12984 13063) 13062 13094
Average time = 13051 Ms.

Java version 1.6.0_13
Java HotSpot (TM) Client VMS
11.3-b02
Sun Microsystems INC.

Direct Call using member field:
47 31 109) 109 31
Average time = Ms.
Direct call using passed value:
16 16 16) 31 15
Average time = Ms.
Call to object using member field:
46 47 47) 47 32
Average time = Ms.
Call to object using passed value:
15 16 31) 16 16
Average time = Ms.
Reflection Call using member field:
812 782 844) 844 844
Average time = 829 Ms.
Reflection call using passed value:
938 953 954) 1031 953
Average time = 973 Ms.

Java version 1.6.0_13
Java HotSpot (TM) Client VMS
11.3-b02
Sun Microsystems INC.

Direct Object Creation:
62 47 78) 32 93
Average time = Ms.
Reflection Object Creation:
125 94 94) 109 187
Average Time = 121 Ms.
Direct Byte[8] Creation:
125 187 94) 172 94
Average Time = 137 Ms.
Reflection Byte[8] Creation:
266 171 187) 188 219
Average time = 191 Ms.
Direct byte[64] Creation:
250 172 156) 125 203
Average Time = 164 Ms.
Reflection byte[64] Creation:
281 219 203) 203 219
Average Time = 211 Ms.

A gorgeous upper layer requires a solid underlying foundation

Http://wiki.apache.org/tomcat/FAQ/Deployment
Http://download.oracle.com/javase/7/docs/webnotes/tsg/TSG-VM/html/memleaks.html#gbyuu

Java heap space, PermGen space error using JVISUALVM monitoring set a reasonable value

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.