[Java] How to Use Java Visual VM to find PermGen Space

Source: Internet
Author: User

This error is always reported when Eclipse uses tomcat to run three projects. The error details are as follows:

13:47:41 org. apache. catalina. core. StandardWrapperValve invoke severe: Servlet. service () for servlet dispatcher-
servlet threw exceptionjava.lang.OutOfMemoryError: PermGen space    at java.lang.ClassLoader.defineClass1(Native Method)    at java.lang.ClassLoader.defineClassCond(Unknown Source)    at java.lang.ClassLoader.defineClass(Unknown Source)    at java.security.SecureClassLoader.defineClass(Unknown Source)

The original know you can set the corresponding parameters can be: http://www.cnblogs.com/garinzhang/archive/2013/03/20/2970901.html

After the attempt, I found that the problem still persists. I will continue to find a solution on the network.

 

Method 1: ModifyCatalina. sh (Linux)/catalina. bat (Windows ):

In Linux, echo "Using CATALINA_BASE: $ CATALINA_BASE" is found through text search, and JAVA_OPTS =-server-XX: PermSize = 64 M-XX: MaxPermSize = 128 m is added.

In Windows, search for echo Using CATALINA_BASE: "% CATALINA_BASE %" and add: set JAVA_OPTS = % JAVA_OPTS %-server-XX: PermSize = 128 m-XX: MaxPermSize = 512 m.

After this method is tried, the exception persists. After the PermSize is changed, restart tomcat and the exception persists.

Method 2: orModify the catalina. sh/bat file:

rem catalina.bat
set JAVA_OPTS=-Xms64m -Xmx256m -XX:PermSize=128m -XX:MaxNewSize=256M -XX:MaxPermSize=256m
#catalina.shJAVA_OPTS=-Xms64m-Xmx256m-XX:PermSize=128m-XX:MaxNewSize=256m-XX:MaxPerSize=256m

Failed to restart tomcat

Method 3:Add the following at the end of Eclipse. ini file:

-Xms256m-Xmx512m-XX:PermSize=512m-XX:MaxPermSize=512m

Restarting Eclipse still fails.

 

The Memory tool can be used to view the memory size. Finally, you can find a solution through the following steps:

1. run the tool jvisualvm.exe (Java VisualVM) in the JDK bin directory to view the PermGen information. For example, if the red box is PermGen and the tab next to it is heap, is the so-called Heap (if the Heap has a problem, you can use it to view it)

Therefore, the memory occupied by PermGen cannot be greater than or equal to the total memory occupied by the VM. If it is set to half, it will be almost the same.

3. At this time, the problem is very clear. Eclipse's tomcat plug-in is definitely not set in the tomcat installation directory, or is overwritten in eclipse. Therefore, find the Tomcat plug-in settings of Eclipse and set them as follows:

Now start tomcat through Eclipse, and this problem will no longer occur.

 

Note: by using Visual VM to view the Eclipse memory, we found that method 3 is actually set to Eclipse, not tomcat, so when the settings are incorrect in the future, when using Visual VM, you must know the problem.

 

 

Refer:

Http://www.cnblogs.com/xwdreamer/archive/2011/11/21/2296930.html

Http://woo-program.iteye.com/blog/1243613

Http://blog.sina.com.cn/s/blog_6840f82901013wk8.html

Http://www.iteye.com/problems/93036

Http://www.mkyong.com/tomcat/tomcat-javalangoutofmemoryerror-permgen-space/

Http://hi.baidu.com/chssheng2007/item/3f8cd7e7d41ed80c8c3ea8c2

Http://hi.baidu.com/ijczwiiukobnorq/item/9d6ca3c35ed80c7788ad9e66

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.