Java 类 (PermGen) 内存泄漏(Web 应用程序)- 通用解决方案?

发布于 2024-08-16 11:12:46 字数 462 浏览 5 评论 0原文

我知道,我有永久代内存泄漏。使用 jvisualvm 进行分析表明,在进行热部署时(例如,在 tomcat、WebSphere、WebLogic 等中,在不终止 JVM 的情况下停止和启动应用程序)- PermGen 空间不断增加。

在阅读、使用 jhat 和其他高级工具后,我意识到我可能从其父类加载器中的某个类引用了 WebAppClassLoader。

即使我在 jhat 上做了一些基于 JavaScript 的大量查询,我也无法确定它

是否有一个简单的实用程序可以找出谁负责您的类加载器不被垃圾收集(从而允许对它加载的类进行垃圾收集) )?

我向所有 LMGTFY 朋友尝试了 JProfiler、jvisualvm、jhat 和大量 Google

- 我花了大约一天半的时间阅读论坛并提供逐步说明,但没有成功。我正在寻找一个实用程序或代码,输出:

类 Y 的对象 X 是防止类被删除的唯一 GC 根。

I have a perm gen memory leak, that I know. Profiling using jvisualvm shows that when doing hot deployment (e.g. stop and start an application without killing the JVM, in tomcat, WebSphere, WebLogic etc) - the PermGen space is constantly increasing.

After reading, using jhat, and other advanced tools I realized that I probably have a reference to the WebAppClassLoader from a class somewhere in its parent class loaders.

I couldn't pin it down even though I did some massive JavaScript based queries on jhat

Isn't there a simple utility that finds out who is responsible for you class loader to not be garbage collected (thus allowing garbage collection of classes loaded by it)?

I tried JProfiler, jvisualvm, jhat, and a lot of Google

to all the LMGTFY friends - I've spent about a day and a half reading forums with step by steps instructions, no luck. I'm looking for a utility or code that outputs:

Object X of class Y is the sole GC root that keeps your classes from being removed.

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

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

发布评论

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

评论(4

洛阳烟雨空心柳 2024-08-23 11:12:47

这里也有一些提示,
http://minmaxmim.blogspot.com/2010/01/javalangoutofmemoryerror- java-heap.html

还请查看 javalangoutofmemoryerror-permgen-space 文章。

Few pointers here as well,
http://minmaxmim.blogspot.com/2010/01/javalangoutofmemoryerror-java-heap.html

also check the javalangoutofmemoryerror-permgen-space article.

泪痕残 2024-08-23 11:12:46

有一个不太令人满意但简单的解决方案:不要在生产环境中进行热部署。您可以设置一个由两个 servlet 容器组成的集群,并且它们通过重新启动一次更新一个。

There is an unsatisfiying but easy solution: Don't hotdeploy in production environments. You could setup a cluster of two servlet containers and them update one at a time with a restart.

逆光飞翔i 2024-08-23 11:12:46

频繁重新部署的现实......
你能做的最好的事情就是使用 -XX:MaxPermSize=256m 增加 perm gen 的大小。每次 jvm 重新启动时,这可能会为您带来更多的重新部署。
或者阅读 http://my.opera.com /karmazilla/blog/2007/03/15/permgen-strikes-back

请注意,如果类加载器根本无法进行GC,那么摆弄jvm根本没有帮助。您最好忘记频繁的部署,尤其是在生产中,但对于开发人员来说它很方便。

The realities of frequent redeployments...
Best you can do is increase the size of perm gen using -XX:MaxPermSize=256m. This may buy you some redeployments more per jvm restart.
Or read on at http://my.opera.com/karmazilla/blog/2007/03/15/permgen-strikes-back

Beware that if the classloaders can't be gc-ed at all, fiddling with the jvm won't help at all. You'd better forget about frequent deployments, especially in production, for dev it's handy, nevertheless.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文