我一直在努力的应用程序一直在展示大量的堆内存使用情况。是否有可能检测到堆外存储泄漏的来源?
我已将应用程序配置为使用4096米的Xms和Xmx。然而,在PID上运行表明该过程耗用机器内存的9.6%(64GB计算机 - >〜6.14克应用程序占用空间)。 这种情况似乎会继续增长,无限期的情况下,实例活着的时间越长。常住人数约为5.9克。使用jvisualvm检查过程我发现大约1.5gb的堆使用情况,具有健康的GC模式。我已经拉堆转储和线程转储,并没有看到任何异常。
我拉了一个pmap的过程。堆大小看起来与应用程序Xms和Xmx参数一致。堆栈大约130Kb。我注意到大量匿名内存:
00000006c0000000 4195968K 1437248K 1437248K 1437248K 0K rw-p [anon]
00000007c01a0000 1046912K 0K 0K 0K 0K ---p [anon]
00007ff712acd000 230464K 0K 0K 0K 0K ---p [anon]
00007ff7077cb000 148452K 10452K 10452K 10452K 0K rw-p [anon]
00007ff711bdd000 15296K 15224K 15224K 15224K 0K rwxp [anon]
00007ff7109c6000 14924K 14692K 14692K 14692K 0K rw-p [anon]
一些示例GC行为:
Java HotSpot(TM) 64-Bit Server VM (25.40-b25) for linux-amd64 JRE (1.8.0_40-b25), built on Feb 10 2015 21:29:53 by "java_re" with gcc 4.3.0 20080428 (Red Hat 4.3.0-8)
Memory: 4k page, physical 65938804k(26225716k free), swap 4200444k(3654604k free)
CommandLine flags: -XX:InitialHeapSize=4294967296 -XX:+ManagementServer -XX:MaxHeapSize=4294967296 -XX:ParallelGCThreads=2 -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseParallelGC
2016-06-12T17:24:21.451-0400: 1339.579: [GC (Allocation Failure) [PSYoungGen: 1048576K->33662K(1223168K)] 1048576K->33670K(4019712K), 0.0644541 secs] [Times: user=0.12 sys=0.01, real=0.07 secs]
2016-06-12T18:00:24.301-0400: 3502.429: [GC (Allocation Failure) [PSYoungGen: 1082238K->34800K(1223168K)] 1082246K->34808K(4019712K), 0.0422048 secs] [Times: user=0.08 sys=0.00, real=0.04 secs]
2016-06-12T18:33:27.654-0400: 5485.782: [GC (Allocation Failure) [PSYoungGen: 1083376K->34960K(1223168K)] 1083384K->34968K(4019712K), 0.0382536 secs] [Times: user=0.07 sys=0.00, real=0.04 secs]
2016-06-12T19:06:29.536-0400: 7467.664: [GC (Allocation Failure) [PSYoungGen: 1083536K->34903K(1223168K)] 1083544K->34911K(4019712K), 0.0377560 secs] [Times: user=0.07 sys=0.00, real=0.04 secs]
2016-06-12T19:37:32.785-0400: 9330.912: [GC (Allocation Failure) [PSYoungGen: 1083479K->34512K(1223168K)] 1083487K->34520K(4019712K), 0.0382442 secs] [Times: user=0.07 sys=0.00, real=0.04 secs]
2016-06-12T20:06:35.474-0400: 11073.602: [GC (Allocation Failure) [PSYoungGen: 1083088K->34624K(1362432K)] 1083096K->34632K(4158976K), 0.0445968 secs] [Times: user=0.07 sys=0.01, real=0.04 secs]
2016-06-12T20:45:03.191-0400: 13381.318: [GC (Allocation Failure) [PSYoungGen: 1361216K->6579K(1333248K)] 1361224K->36444K(4129792K), 0.0489775 secs] [Times: user=0.08 sys=0.01, real=0.05 secs]
2016-06-12T21:20:41.637-0400: 15519.764: [GC (Allocation Failure) [PSYoungGen: 1333171K->6080K(1349120K)] 1363036K->36112K(4145664K), 0.0122650 secs] [Times: user=0.01 sys=0.01, real=0.01 secs]
2016-06-12T21:56:05.197-0400: 17643.325: [GC (Allocation Failure) [PSYoungGen: 1313728K->5728K(1313792K)] 1343760K->36072K(4110336K), 0.0107582 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]
2016-06-12T22:32:47.264-0400: 19845.391: [GC (Allocation Failure) [PSYoungGen: 1313376K->5728K(1347584K)] 1343720K->36512K(4144128K), 0.0113968 secs] [Times: user=0.03 sys=0.00, real=0.00 secs]
应用程序有大约15个线程。在Sles 11 sp3机器上的JVM是jdk-1.8.0_40。
我的问题是:
这似乎是在应用大大增长离堆的问题。这是安全的假设,还是我错过了什么?
有没有办法查明内存消耗来自哪里?
您提供的数字都不是无限增长的指标。你可能不应该看堆使用的数字,而是堆分配的数据。 – the8472
是的,请参阅http://stackoverflow.com/a/35610063/166062 –