最近写了个服务器小程序,开的线程比较多,大约在1000左右吧,高峰期会更多。
今天忽然不停的GC,觉得很纳闷,不知道是怎么一回事,应该如何去做优化?
GC日志如下:一次GC的时间间隔不到一秒,每次GC的时间也不到一秒。
{Heap before GC invocations=306 (full 0):
par new generation total 511936K, used 511872K [0x000000007fff0000, 0x000000009f3f0000, 0x000000009f3f0000)
eden space 511872K, 100% used [0x000000007fff0000, 0x000000009f3d0000, 0x000000009f3d0000)
from space 64K, 0% used [0x000000009f3d0000, 0x000000009f3d0000, 0x000000009f3e0000)
to space 64K, 0% used [0x000000009f3e0000, 0x000000009f3e0000, 0x000000009f3f0000)
concurrent mark-sweep generation total 5632000K, used 145047K [0x000000009f3f0000, 0x00000001f6ff0000, 0x00000001f6ff0000)
concurrent-mark-sweep perm gen total 512000K, used 35276K [0x00000001f6ff0000, 0x00000002163f0000, 0x00000002163f0000)
158889.595: [GC 158889.595: [ParNew: 511872K->0K(511936K), 0.0029090 secs] 656919K->145050K(6143936K), 0.0030557 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
Heap after GC invocations=307 (full 0):
JVM的配置参数如下:
-Xms6000M -Xmx6000M -Xmn500M -XX:PermSize=500M -XX:MaxPermSize=500M -XX:SurvivorRatio=65536 -XX:MaxTenuringThreshold=0 -Xnoclassgc -XX:+DisableExplicitGC -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:+CMSClassUnloadingEnabled -XX:-CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=90 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+PrintClassHistogram -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC