检测Web应用程序中的内存泄漏

时间:2011-07-20 00:42:01

标签: tomcat memory memory-leaks

我们有一个用gwt编写并在tomcat中部署的Web应用程序。 tomcat在outofmemoryexception上崩溃,所以我试图使用Jprofiler,jmap / jhat实用程序等来查找内存泄漏。

以下是我看到的问题,并感谢专家帮助追踪问题。

我已将tomcat配置为使用-Xmx1600m -Xms1024m运行并启用gc日志记录。当我在运行应用程序几个小时后看到gc日志时,我看到以下内容,

9850.373: [GC [PSYoungGen: 301459K->10630K(341504K)] 943137K->663019K(1269952K), 0.1711120 secs] [Times: user=0.32 sys=0.02, real=0.17 secs]
9864.412: [GC [PSYoungGen: 320588K->14287K(341376K)] 972976K->668772K(1269824K), 0.1604710 secs] [Times: user=0.24 sys=0.00, real=0.16 secs]
9874.808: [GC [PSYoungGen: 324431K->7800K(377792K)] 978916K->666111K(1306240K), 0.1253720 secs] [Times: user=0.21 sys=0.04, real=0.12 secs]
9884.888: [GC [PSYoungGen: 355320K->7639K(377920K)] 1013631K->670793K(1306368K), 0.1563460 secs] [Times: user=0.23 sys=0.01, real=0.15 secs]
9897.209: [GC [PSYoungGen: 355159K->9687K(423552K)] 1018313K->676330K(1352000K), 0.1368880 secs] [Times: user=0.22 sys=0.05, real=0.14 secs]
9913.372: [GC [PSYoungGen: 403927K->5599K(424000K)] 1070570K->675351K(1352448K), 0.1599430 secs] [Times: user=0.21 sys=0.02, real=0.16 secs]
9999.866: [GC [PSYoungGen: 399839K->6655K(468480K)] 1069591K->678050K(1396928K), 0.2453910 secs] [Times: user=0.37 sys=0.03, real=0.24 secs]
10104.177: [GC [PSYoungGen: 449919K->10830K(472576K)] 1121314K->688787K(1401024K), 0.1271810 secs] [Times: user=0.20 sys=0.03, real=0.12 secs]
10114.859: [GC [PSYoungGen: 454094K->7316K(514240K)] 1132051K->694401K(1442688K), 0.1046640 secs] [Times: user=0.15 sys=0.05, real=0.10 secs]
10127.079: [GC [PSYoungGen: 496084K->6783K(516160K)] 1183169K->699705K(1444608K), 0.1004840 secs] [Times: user=0.17 sys=0.03, real=0.10 secs]
10136.380: [GC [PSYoungGen: 495551K->8800K(516096K)] 1188473K->707881K(1444544K), 0.1615950 secs] [Times: user=0.28 sys=0.04, real=0.16 secs]
10151.757: [GC [PSYoungGen: 500704K->13808K(517696K)] 1199785K->716602K(1446144K), 0.2068230 secs] [Times: user=0.32 sys=0.09, real=0.20 secs]
10184.481: [GC [PSYoungGen: 505712K->4543K(519488K)] 1208506K->716201K(1447936K), 0.2158960 secs] [Times: user=0.32 sys=0.05, real=0.22 secs]
10206.485: [GC [PSYoungGen: 499647K->12190K(520192K)] 1211305K->728137K(1448640K), 0.2251280 secs]

我对gc.log的理解如下,

年轻一代在垃圾收集后使用12190K。 老一代在垃圾收集后使用728137K。

总的来说,应用程序使用的是740M。我的理解是对的吗?

如果没有,这个日志文件的正确解释是什么?

如果是的话,我还看了一下使用htop(我在linux上运行它)的系统资源使用情况,这表明tomcat进程正在使用1419M。

为什么内存使用会有所不同?

感谢您的帮助! 感谢。

1 个答案:

答案 0 :(得分:0)

GWT Requestfactory中存在内存泄漏,已在2.4中修复。我刚升级到那个,一切都很好。

相关问题