Java堆中的constantPoolClass? [英] constantPoolClass in Java heap?

查看:616
本文介绍了Java堆中的constantPoolClass?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一个Java applet(一个实际的< APPLET>),它在运行大约4天后抛出一个OutOfMemory异常。小程序的性质使得人们真的会长时间保持打开状态。

I have inherited a Java applet (an actual <APPLET>) which throws an OutOfMemory exception after about 4 days of runtime. The nature of the applet is such that people really will leave it open for long periods of time.

运行近两天后,jmap -histo将顶级堆消费者显示为:

After almost two days running, jmap -histo shows the top heap consumers as:


    num  #instances   #bytes  class name
    ---  ----------   ------  ----------
      1:      14277  7321880  <constantPoolKlass>
      2:      59626  5699968  <constMethodKlass>
      3:      14047  5479424  <constantPoolCacheKlass>
      4:      14277  5229744  <instanceKlassKlass>
      5:      59626  4778944  <methodKlass>
      6:      71026  3147624  <symbolKlass>

麻烦的是,我不明白这些是什么。至少有两件事情发生:constantPoolKlass + constantPoolCacheKlass + instanceKlassKlass看起来是相关的,constMethodKlass + methodKlass也是如此。从名称来看,它们似乎与类加载器相关。

The trouble is, I don't understand what any of these things are. There are at least two things going on: constantPoolKlass+constantPoolCacheKlass+instanceKlassKlass appear related, as do constMethodKlass+methodKlass. From the names, they appear related to a class loader.

如果我不得不猜测我会说applet创建了大约14,277个对象,其中每个对象有大约4个方法,总计约59626种方法。然而,jmap输出并没有显示任何具有如此大量实例的类,也没有看起来像其他类对象的总和加起来为14277.所以也许我对这些对象的作用不正确。有人可以解释一下吗?

If I had to guess I'd say the applet has creating about 14,277 objects where each object has about 4 methods, for about 59626 methods total. Yet the jmap output doesn't show any class with such a large number of instances, nor does it look like the sum total of other class objects add up to 14277. So maybe I'm incorrect about what these objects do. Can someone explain?

推荐答案

是的,看起来你正在泄漏类加载器。如果您实际上没有在自己的代码中创建类加载器(通常通过URLClassLoader.newInstance或XSLT),那么它可能与重新加载applet有关(尽管您通常会返回相同的类加载器)。泄漏的可能原因是ThreadLocal,JDBC驱动程序和java.beans。

Yup, looks like you are leaking class loaders. If you're not actually creating class loaders in you own code (typically through URLClassLoader.newInstance or XSLT) then it may be related to reloading the applet (although you would usually get back the same class loader). Possible causes of leaks are ThreadLocal, JDBC drivers and java.beans.

这篇关于Java堆中的constantPoolClass?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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