java.lang.OutOfMemoryError:PermGen 空间(不是通常的嫌疑人!)

发布于 2024-12-17 15:31:34 字数 743 浏览 1 评论 0原文

jsp页面中的这一行就出现错误!

    <table:table name="sessionScope.users" sort="external" pagesize="50" id="user" class="list" 
    requestURI="/admin-users.html" partialList="true" size="sessionScope.fullListSize">

我尝试使用其他帖子中的方法将 perm gen max 增加到 512m,无论是对于 eclipse 的调用还是 Tomcat 的实例。

好的,所以需要更多的上下文:这是我的开发系统,在 eclipse 中运行,并指向一个独立的 tomcat 实例,它是 Eclipse 中的服务器。

根据 Recurring "PermGen" in Tomcat 6,我的 Eclipse 中有以下内容。文件名:

--launcher.XXMaxPermSize
512m

// ...

-XX:MaxPermSize=512m
-XX:+UseConcMarkSweepGC
-XX:+CMSPermGenSweepingEnabled
-XX:+CMSClassUnloadingEnabled
-Xms256m


-Xmx512m

The error occurs on this line in a jsp page!

    <table:table name="sessionScope.users" sort="external" pagesize="50" id="user" class="list" 
    requestURI="/admin-users.html" partialList="true" size="sessionScope.fullListSize">

I've tried increasing the perm gen max to 512m, using the methods found in other posts, both for the invocation of eclipse and the instance of Tomcat.

Ok, so a bit more context is required: THis is my dev system, running in eclipse, and pointing to a standalone instance of tomcat that is a server within Eclipse.

According to Recurring "PermGen" in Tomcat 6, I have the following in my eclipse.ini:

--launcher.XXMaxPermSize
512m

// ...

-XX:MaxPermSize=512m
-XX:+UseConcMarkSweepGC
-XX:+CMSPermGenSweepingEnabled
-XX:+CMSClassUnloadingEnabled
-Xms256m


-Xmx512m

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朮生 2024-12-24 15:31:34

一个编写良好的 Web 应用程序在重新部署时不应该保留其类加载器,但有很多原因会导致这种情况。

如果您在 Tomcat 上运行,您可能想在 server.xml 中尝试以下操作:

<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />

此页面有更多信息。

A well-written webapp shouldn't hang onto its classloader when redeployed, but there are numerous reasons why it might.

If you're running on Tomcat, you might like to try this in the server.xml:

<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />

This page has much more info.

属性 2024-12-24 15:31:34

您可能向 Tomcat 重新部署了太多次。反弹 Tomcat 就可以了 - 直到您再次通过太多的重新启动填满了永久代空间。

更新:

如果您每次点击该页面时都会发生这种情况,我会担心您的页面正在做什么。 JSP 是 servlet 的模板,随后将其编译为 .class 文件。如果该 JSP 太大以至于填满了您的永久代空间,那么您就会遇到一个大问题。

所有关于泄漏检测的建议对我来说似乎都是错误的。泄漏通常会随着时间的推移而显现出来。您在下面说过,每次访问都会发生这种情况。

我建议如下:

  1. 将 Eclipse 排除在外。如果您手动部署 WAR 并启动 Tomcat,您是否会观察到相同的行为? Eclipse 启动可能是错误的。
  2. 您可以调整内存和永久代空间的大小。 Google 查找 JVM 选项并了解如何操作。
  3. 下载 Visual VM 1.3.3,安装所有插件,并在运行 Tomcat 之前启动它。我会让你实时看到你的记忆发生了什么。您还可以看到许多其他有用的东西,例如线程等。您需要更多数据,而不是猜测。

You probably redeployed one time too many to Tomcat. Bounce Tomcat and it'll be fine - until you've filled up the perm gen space with too many restarts again.

UPDATE:

I'd be worried about what your page is doing if it's happening every single time you hit that page. A JSP is a template for a servlet, which is subsequently compiled into a .class file. You've got a big problem if that JSP is so big that it's filling up your perm gen space.

All the suggestions about leak detection seem wrong headed to me. Leaks usually manifest themselves over time. You said below that it happens on every access.

I'd recommend the following:

  1. Leave Eclipse out of it. If you deploy a WAR by hand and start up Tomcat, do you observe the same behavior? The Eclipse start up might be wrong.
  2. You can adjust the size of memory and perm gen space. Google for JVM options and see how to do it.
  3. Download Visual VM 1.3.3, install all the plugins, and start it before you run Tomcat. I'll let you see what's happening to your memory in real time. You can see lots of other useful things as well, like threads, etc. You need more data, not guesses.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文