运行几个小时后,我的http服务器开始频繁地使用主gc,但没有释放堆。
几次主要gc之后,出现了promotion failed和concurrent mode failure,然后堆被释放。我的gc日志如下:
{Heap before GC invocations=7172 (full 720):
par new generation total 737280K, used 667492K [0x000000076b800000, 0x000000079d800000, 0x000000079d800000)
eden space 655360K, 100% used [0x000000076b800000, 0x0000000793800000, 0x0000000793800000)
from space 81920K, 14% used [0x0000000793800000, 0x00000007943d91d0, 0x0000000798800000)
to space 81920K, 0% used [0x0000000798800000, 0x0000000798800000, 0x000000079d800000)
concurrent mark-sweep generation total 1482752K, used 1479471K [0x000000079d800000, 0x00000007f8000000, 0x00000007f8000000)
concurrent-mark-sweep perm gen total 131072K, used 58091K [0x00000007f8000000, 0x0000000800000000, 0x0000000800000000)
2015-11-19T21:50:02.692+0800: 113963.532: [GC2015-11-19T21:50:02.692+0800: 113963.532: [ParNew (promotion failed)
Desired survivor size 41943040 bytes, new threshold 15 (max 15)
- age 1: 3826144 bytes, 3826144 total
- age 2: 305696 bytes, 4131840 total
- age 3: 181416 bytes, 4313256 total
- age 4: 940632 bytes, 5253888 total
- age 5: 88368 bytes, 5342256 total
- age 6: 159840 bytes, 5502096 total
- age 7: 733856 bytes, 6235952 total
- age 8: 64712 bytes, 6300664 total
- age 9: 314304 bytes, 6614968 total
- age 10: 587160 bytes, 7202128 total
- age 11: 38728 bytes, 7240856 total
- age 12: 221160 bytes, 7462016 total
- age 13: 648376 bytes, 8110392 total
- age 14: 33296 bytes, 8143688 total
- age 15: 380768 bytes, 8524456 total
: 667492K->665908K(737280K), 0.7665810 secs]2015-11-19T21:50:03.459+0800: 113964.299: [CMS2015-11-19T21:50:05.161+0800: 113966.001: [CMS-concurrent-mark: 3.579/4.747 secs] [Times: user=13.41 sys=0.35, rea
l=4.75 secs]
(concurrent mode failure): 1479910K->44010K(1482752K), 4.7267420 secs] 2146964K->44010K(2220032K), [CMS Perm : 58091K->57795K(131072K)], 5.4939440 secs] [Times: user=9.07 sys=0.13, real=5.49 secs]
Heap after GC invocations=7173 (full 721):
par new generation total 737280K, used 0K [0x000000076b800000, 0x000000079d800000, 0x000000079d800000)
eden space 655360K, 0% used [0x000000076b800000, 0x000000076b800000, 0x0000000793800000)
from space 81920K, 0% used [0x0000000798800000, 0x0000000798800000, 0x000000079d800000)
to space 81920K, 0% used [0x0000000793800000, 0x0000000793800000, 0x0000000798800000)
concurrent mark-sweep generation total 1482752K, used 44010K [0x000000079d800000, 0x00000007f8000000, 0x00000007f8000000)
concurrent-mark-sweep perm gen total 131072K, used 57795K [0x00000007f8000000, 0x0000000800000000, 0x0000000800000000)
} CMS GC似乎没有任何意义。你能给我解释一下吗?
这是我的gc配置:
/usr/local/jdk1.7.0_79/bin/java
-server
-Xms2248m
-Xmx2248m
-Xmn800m
-XX:PermSize=128m
-XX:MaxPermSize=128m
-XX:MaxTenuringThreshold=15
-XX:+UseCMSCompactAtFullCollection
-XX:CMSFullGCsBeforeCompaction=0
-XX:+UseConcMarkSweepGC
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintGCDateStamps
-Xloggc:gc.log
-XX:+PrintHeapAtGC
-XX:+PrintTenuringDistribution
-XX:+UseFastAccessorMethods更新
自服务器启动以来,有一个定期任务。它的工作是从mysql加载数据并保存在jvm堆中。当客户端请求出现时,服务器应该使用数据进行计算。这样的任务代码:
private volatile List<ActivityInfo> activityInfos;
public void run () {
activityInfos = db.loadActivity();
}
public ActivityInfo getActivityByClient() {
//
List<ActivityInfo> local = activityInfos;
// biz code
ActivityInfo response = // biz code
return response;
}
// executor
executor.scheduleWithFixedDelay(task, 0, 1, TimeUnit.MINUTES);最让我困惑的是,为什么堆在满gc之后才被释放,而不是在主gc之后释放?
更新
发布于 2015-11-22 02:09:07
这意味着您的运行非常接近您的最大堆大小,因此有频繁的GC,但很少被释放。试着大幅增加,比如增加1.5倍或2倍。
发布于 2015-11-25 17:46:01
为了解决这个问题,您可以使用Eclipse 。它将向您详细展示所有这些与内存和线程相关的问题。您还可以使用jConsole来实现它。
https://stackoverflow.com/questions/33806952
复制相似问题