这是gc的日志, 部分如下
6.112: [GC 6.112: [ParNew: 419456K->21462K(471872K), 0.0248290 secs] 419456K->21462K(1508160K), 0.0249350 secs] [Times: user=0.14 sys=0.03, real=0.02 secs] 
44.747: [GC 44.747: [ParNew: 440918K->47728K(471872K), 0.0408050 secs] 440918K->47728K(1508160K), 0.0409110 secs] [Times: user=0.23 sys=0.05, real=0.04 secs] 
4451.090: [GC 4451.090: [ParNew: 467184K->52416K(471872K), 0.0858570 secs] 467184K->72837K(1508160K), 0.0859740 secs] [Times: user=0.36 sys=0.08, real=0.08 secs] 
24332.651: [GC 24332.651: [ParNew: 471872K->50315K(471872K), 0.0700180 secs] 492293K->89935K(1508160K), 0.0701360 secs] [Times: user=0.27 sys=0.06, real=0.07 secs] 
46893.106: [GC 46893.106: [ParNew: 469771K->37488K(471872K), 0.0171660 secs] 509391K->77108K(1508160K), 0.0172740 secs] [Times: user=0.12 sys=0.00, real=0.02 secs] 
71262.886: [GC 71262.886: [ParNew: 456944K->39857K(471872K), 0.0169400 secs] 496564K->79476K(1508160K), 0.0170540 secs]
Total time for which application threads were stopped: 0.0001050 seconds
Heap
 par new generation   total 471872K, used 270854K [0x00002aaaae630000, 0x00002aaace630000, 0x00002aaace630000)
  eden space 419456K,  61% used [0x00002aaaae630000, 0x00002aaabe1ca938, 0x00002aaac7fd0000)
  from space 52416K,  25% used [0x00002aaac7fd0000, 0x00002aaac8cb72b8, 0x00002aaacb300000)
  to   space 52416K,   0% used [0x00002aaacb300000, 0x00002aaacb300000, 0x00002aaace630000)
 concurrent -sweep generation total 1036288K, used 79234K [0x00002aaace630000, 0x00002aab0da30000, 0x00002aab0da30000)
 concurrent--sweep perm gen total 262144K, used 76522K [0x00002aab0da30000, 0x00002aab1da30000, 0x00002aab1da30000)
Application time: 0.0631700 seconds
大侠们,看看是什么问题啊, 有时候OutOfMerrory: PermGen Space, 用了spring

解决方案 »

  1.   

    我的resin配置,resin.xml<!--
       - Resin 4.0 configuration file.
       -
       - See conf/full.xml for more sample configuration, including load
       - balancing and database configuration.
      -->
    <resin xmlns="http://caucho.com/ns/resin"
           xmlns:resin="urn:java:com.caucho.resin">  <!--
         - Logging configuration for the JDK logging API.
        -->
      <log-handler name="" level="all" path="stdout:"
                   timestamp="[%y-%m-%d %H:%M:%S.%s] {%{thread}} "/>  <!--
         - level='info' for production
         - 'fine' or 'finer' for development and troubleshooting
        -->
      <logger name="com.caucho" level="info"/>  <logger name="com.caucho.java" level="config"/>
      <logger name="com.caucho.loader" level="config"/>  <!--
         - driver .jar files can be placed in ${resin.root}/ext-lib
         -->
      <class-loader>
        <tree-loader path="${resin.root}/ext-lib"/>
      </class-loader>
      
      <!--
         - Remote management requires at least one enabled admin user.
        -->
      <resin:AdminAuthenticator>
        <resin:import path="${__DIR__}/admin-users.xml" optional="true"/>
      </resin:AdminAuthenticator>  <!--
         - For production sites, change dependency-check-interval to something
         - like 600s, so it only checks for updates every 10 minutes.
        -->
      <dependency-check-interval>2s</dependency-check-interval>  <!-- Java system-properties -->
      <system-property mail.smtp.host="127.0.0.1"/>
      <system-property mail.smtp.port="25"/>  <!--
         - default configuration applied to all clusters
        -->
      <cluster-default>
        <!-- standard servlet behavior, including .jsp, .php, and WEB-INF -->
        <resin:import path="${__DIR__}/app-default.xml"/>    <!-- enables development error pages -->
        <development-mode-error-page/>    <!--
           - Enables the proxy cache (available in Resin Professional) 
          -->
        <resin:if test="${resin.professional}">
          <cache memory-size="64M">
           <!-- Vary header rewriting for IE -->
            <rewrite-vary-as-private/>
          </cache>
        </resin:if>
        
        <!--
           - Admin services
          -->
        <resin:DeployService/>
        
        <resin:if test="${resin.professional}">
          <resin:JmxService/>
          <resin:LogService/>
          <resin:StatService/>
          <resin:XaLogService/>
        </resin:if>         <database>
               <jndi-name>jdbc/shop</jndi-name>
               <driver type="com.mysql.jdbc.Driver">
                 <url>jdbc:mysql://218.240.39.69:3306/shop?useUnicode=true&amp;charactorEncoding=UTF-8</url>
                 <user>zhaoyu</user>
                 <password>zhaoyu</password>
                </driver>
                <prepared-statement-cache-size>8</prepared-statement-cache-size>
                <max-connections>20</max-connections>
                <max-idle-time>30s</max-idle-time>
              </database>    <!--
           - Default host configuration applied to all virtual hosts.
          -->
        <host-default>
          <access-log path="log/access.log" 
                    format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
                    rollover-period="1W"/>      <!-- creates the webapps directory for .war expansion -->
          <web-app-deploy path="webapps"/>      <!--
             - Defaults applied to each web-app.
            -->
          <web-app-default>
            <prologue>
              <allow-servlet-el/>
            </prologue>        <!-- enable persistent sessions -->
            <session-config>
              <use-persistent-store/>
            </session-config>
         
            <!--
               - Sets max-age for cacheable pages, e.g. static pages.
              -->
            <resin:if test="${resin.professional}">
              <cache-mapping url-pattern="/" max-age="5s"/>
              <cache-mapping url-pattern="*.gif" max-age="60s"/>
              <cache-mapping url-pattern="*.jpg" max-age="60s"/>
              <cache-mapping url-pattern="*.png" max-age="60s"/>
              <cache-mapping url-pattern="*.css" max-age="60s"/>
              <cache-mapping url-pattern="*.js" max-age="60s"/>
             </resin:if>
          </web-app-default>
        </host-default>
      </cluster-default>  <!--
         - Configures the main appliction cluster.  Load-balancing configurations
         - will also have a load-balance-tier cluster.
        -->
      <cluster id="app-tier">
        <!-- sets the content root for the cluster, relative to resin.root -->
        <root-directory>.</root-directory>
        <!-- defaults for each server, i.e. JVM -->
        <server-default>
          <!-- The http port -->
          <http address="*" port="8080"/>
          <!-- SSL port configuration: -->
          <http address="*" port="8443">
            <jsse-ssl self-signed-certificate-name="resin@localhost"/>
          </http>
          
          <jvm-arg>-server</jvm-arg>
      <jvm-arg>-Xms1524M</jvm-arg>
      <jvm-arg>-Xmx1524M</jvm-arg>
      <jvm-arg>-Xmn512M</jvm-arg>
      <jvm-arg>-Xss1M</jvm-arg>
    <jvm-arg>-XX:PermSize=256M</jvm-arg>
      <jvm-arg>-XX:MaxPermSize=256M</jvm-arg> 
      <jvm-arg>-XX:SurvivorRatio=8</jvm-arg>
      <jvm-arg>-XX:MaxTenuringThreshold=7</jvm-arg>
      <jvm-arg>-XX:GCTimeRatio=19</jvm-arg>
      <jvm-arg>-XX:+UseParNewGC</jvm-arg>
      <jvm-arg>-XX:+UseConcMarkSweepGC</jvm-arg>
      <jvm-arg>-XX:+CMSPermGenSweepingEnabled</jvm-arg>
      <jvm-arg>-XX:+CMSClassUnloadingEnabled</jvm-arg> 
      <jvm-arg>-XX:+UseCMSCompactAtFullCollection</jvm-arg>
      <jvm-arg>-XX:CMSFullGCsBeforeCompaction=2</jvm-arg>
      <jvm-arg>-XX:-CMSParallelReEnabled</jvm-arg>
      <jvm-arg>-XX:+DisableExplicitGC</jvm-arg> 
      <jvm-arg>-XX:CMSInitiatingOccupancyFraction=70</jvm-arg>
      <jvm-arg>-XX:SoftRefLRUPolicyMSPerMB=0</jvm-arg>
      <jvm-arg>-XX:+PrintClassHistogram</jvm-arg>
      <jvm-arg>-XX:+PrintGCDetails</jvm-arg>
      <jvm-arg>-XX:+PrintGCTimeStamps</jvm-arg>
      <jvm-arg>-XX:+PrintGCApplicationConcurrentTime</jvm-arg>
      <jvm-arg>-XX:+PrintGCApplicationStoppedTime</jvm-arg>  
      <jvm-arg>-Xloggc:log/gc.log</jvm-arg> <!--
             - <jvm-arg>-agentlib:resin</jvm-arg>
            -->      <!--
             - If starting Resin as root on Unix, specify the user name
             - and group name for the web server user.
            -->
          <resin:if test="${resin.userName == 'root'}">
            <user-name>apache</user-name>
            <group-name>apache</group-name>
          </resin:if>
        </server-default>
        
        <!-- define the servers in the cluster -->
        <server id="" address="127.0.0.1" port="6800">
        </server>    <!-- the default host, matching any host name -->
        <host id="" root-directory=".">
          <!--
             - configures an explicit root web-app matching the
             - webapp's ROOT
            -->
          <web-app id="/" root-directory="/home/apache/htdocs"/>
          
          <!--
             - Administration application /resin-admin
            -->
          <web-app id="/resin-admin" root-directory="${resin.root}/doc/admin">
            <prologue>
              <resin:set var="resin_admin_external" value="false"/>
              <resin:set var="resin_admin_insecure" value="true"/>
            </prologue>
          </web-app>      <!--
     - Resin documentation - remove for a live site
    -->
          <web-app id="/resin-doc" root-directory="${resin.root}/doc/resin-doc"/>      <!--
     - <resin:LoadBalance regexp="^/load" cluster="backend-tier"/>
     - <resin:HttpProxy regexp="^/http" address="localhost:9000"/>
     - <resin:FastCgiProxy regexp="^/fcgi" address="localhost:9001"/>
    -->
        </host>
      </cluster>
    </resin>
      

  2.   

    加载很多类?
    还是频繁的重新部署使用了Spring的应用?
      

  3.   

    动态加载了一些类, 星期五下午6点重启了resin, 等星期天上午9点发现, 项目又访问不了了, 但是项目的主页可以访问
    点查询就很慢, 显示不了
      

  4.   

    动态加载了一些类?数量有多大?频度?是否频繁重启应用?
    permgen size 多大?class info存放在permgen区,加载很多类会导致permgen outofmemory
    另外潜在问题一个是permgen size过小,导致加载的量大就用光了
      

  5.   

    OutOfMerrory: PermGen Space
    默认的这个只有4M
    spring等会频繁产生class
    这个space就不够用了
    在jvm的启动参数里面显式设定下就行
      

  6.   

    动态加载的类就是那些action(5个), 然后5个对应的service, 之前我重启resin频繁(改了些类) 但是星期五之后就没重启
    项目访问不了, 只能重启, 我设置了PermGen了             <jvm-arg>-XX:PermSize=256M</jvm-arg>
                 <jvm-arg>-XX:MaxPermSize=256M</jvm-arg> 
      

  7.   

    以前我也碰到过类似的情况
    之前用的是前人留下的框架默认的Apache DBCP连接池,系统运行一段时间后,主页可以访问,但是一到要查询数据库的时候,就出现服务器不响应的情况。因为DBCP这个东西有内存泄漏的情况的·一段时间后系统将因为资源被占用完,出现系统完全瘫痪的情况。
    后面改用了C3P0的连接方式,问题就解决了。
    另外,楼主好好检查是否有数据库连接后没有释放关闭连接,如果没有也会经常出OutOfMerrory这种问题
      

  8.   

    楼上的朋友我的确用的默认的DBCP连接, 该项目用了两个数据库, 一个用的jdbc操纵, 一个用的hibernate操纵<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${driverClassName}" />
    <property name="url" value="${url}" />
    <property name="username" value="${username}" />
    <property name="password" value="${password}" />
    <!-- 连接池启动时的初始值 -->  
            <property name="initialSize" value="1"/>
    <!-- 连接池的最大值 -->
    <property name="maxActive" value="40"/>
    <!-- 最大空闲值 -->
    <property name="maxIdle" value="5"/>
    <!-- 最小空闲值 -->
    <property name="minIdle" value="2"/>  
    </bean>
      

  9.   

    那你改用C3P0连接试试
    我用的是c3p0-0.8.5.2.jar 包
    <bean id="DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="com.mysql.jdbc.Driver"/>
    <property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:3306/root?useUnicode=true&amp;characterEncoding=UTF-8"/>
    <property name="user" value="***"/>
    <property name="password" value="***"/>
    <property name="maxPoolSize" value="100"/><!--连接池中保留的最大连接数 -->
    <property name="minPoolSize" value="2"/><!--连接池中保留的最小连接数 -->
    <property name="initialPoolSize" value="10"/>
    <property name="maxIdleTime" value="1800"/><!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃-->
    <property name="acquireIncrement" value="3" /><!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数-->
    <property name="maxStatements" value="1000" />
    <property name="acquireRetryAttempts" value="10" /><!-- 定义在从数据库获取新连接失败后重复尝试的次数-->
    <property name="idleConnectionTestPeriod" value="60" /><!--每60秒检查所有连接池中的空闲连接-->
    <property name="breakAfterAcquireFailure" value="true" />
    <property name="testConnectionOnCheckout" value="false" />
        
        </bean>