Tomcat内存使用情况(PermGen) [英] Tomcat memory usage (PermGen)

查看:339
本文介绍了Tomcat内存使用情况(PermGen)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Tomcat部署具有以下PermGen配置的Web应用程序:

I am using Tomcat for deploying a web application withe following PermGen configurations:

JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 
-server -Xms1536m -Xmx1536m
-XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m 
-XX:MaxPermSize=256m -XX:+DisableExplicitGC"

请知道以下内容:


  1. Tomcat使用的整个内存是256MB还是Tomcat因其他原因消耗其他内存?

  2. 我该怎么办?监视Tomcat使用的内存以避免达到PemGen最大大小?

另请注意,我有3只拥有相同PermGen的Tomcats配置,在8 GB Ram的同一物理服务器上运行,这让我害怕将PermGen最大大小增加到512MB而不影响物理服务器内存。

Also please be noticed that I have 3 Tomcats with the same previous PermGen configurations, running on the same physical server with 8 GB Ram which make me afraid of increasing PermGen max size to 512MB not to affect the physical server memory.

推荐答案

Tomcat中的Permgen OOME通常属于组合两件事:

Permgen OOMEs in Tomcat are typically due a combination of two things:


  • 热重新部署。

  • Hot redeployment.

内存泄漏,其中一些引用导致旧的类加载器及其所有依赖对象保持可访问。

Memory leaks where some reference causes an old classloader and all of its dependent objects to remain reachable.

因此,那里有几种方法可以避免这个问题:

Consequently, there are a couple of ways to avoid this problem:


  • 不要进行热重新部署。或者重新启动每一次热重新部署。

  • Don't do hot redeploys. Or restart every few hot redeploys.

跟踪并修复与类加载器相关的存储泄漏。

Track down and fix the classloader-related storage leaks.

增加permgen大小不会阻止问题,但可能会增加OOME问题之间的间隔。 (或者允许你少做一次完整的Tomcat关机/重启。)

Increasing the permgen size won't prevent the problem, but it is likely to increase the interval between OOME problems. (Or allow you to do a full Tomcat shutdown / restart less often.)

你的问题:


1)Tomcat使用的整个内存是256MB还是Tomcat因其他原因占用其他内存?

1) Is the whole memory used by Tomcat should be 256MB or Tomcat consumes other memory for other reasons ?

见上文。它不是专门的Tomcat,尽管Tomcat特别容易出现这种情况。 (显然,Hibernate也可以......我相信它应用于动态代理。)

See above. It is not specifically Tomcat, though Tomcat is particularly prone to this. (Apparently, Hibernate can be too ... due, I believe, to its use of dynamic proxies.)


2)我怎么能监控Tomcat使用的内存以避免达到PemGen最大大小?

2) How can I monitor the memory used by Tomcat to avoid reaching PemGen max size ?

有多种方法可以监控内存使用情况;例如附加代理人。但是,这些不会阻止这个问题。 IMO,更改生产服务器的管理程序会更简单,这样您就不需要进行热重新部署。

There are ways to monitor memory usage; e.g. attaching an agent. However, these won't prevent the problem. IMO, it would be simpler to change your management procedures for your production server(s) so that you don't need to do hot redeploys.

这篇关于Tomcat内存使用情况(PermGen)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆