java - 正常的应用多久一次Full GC?
天蓬老师
天蓬老师 2017-04-18 10:48:22
0
3
1747

我查看我们服务器的状态,半个月发生了900+次full gc,大约20分钟一次full gc,这是正常的吗?或者说优化到多久一次会比较合理?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all (3)
PHPzhong

Although it has not been optimized. However, I feel that this needs to be supported based on actual business needs and business capabilities to optimize it.

    大家讲道理

    Look at the heap size and qps of the Java application, but initially looking at the full gc every 20 minutes, it seems not normal

      PHPzhong

      JVM optimization can be discussed for hours. Here I will give you some simple opinions without going into systematic details.

      First: Your problem is that full gc is frequent. Check whether the total memory and old generation settings are too small.
      It mainly depends on the parameters -Xmx and -Xmn. If it is too small, gc will inevitably occur frequently.

      Second: Add the following parameters
      -verbose.gc -XX:+PrintGC -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:+PrintTenuringDistribution - Xloggc:/data/log/xxx/xxx-gc.log -XX:+PrintGCDetails
      Check how much space is left in the old generation after each gc. Generally speaking, the space in the old generation is set to 2-2.5 times the memory after gc is a more reasonable value.
      At the same time, you can see through this log whether a large number of objects enter the old generation without sufficient gc in the new generation. If objects that can be recycled through the new generation enter the old generation, full gc will inevitably occur frequently

      Third: Code reason dump memory
      jmap -dump:live,format=b,file=xx.bin [pid]
      Then look at it through the MAT (http://www.eclipse.org/mat/) tool Which large piece of memory has not been released?

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!