开发者

Determine size of single Java class definition in PermGen space?

How do I determine how large a single, specific class definition (not the instantiated object) is? Specifically, how much PermGen memory does a given class use? If it cannot be calculated, how roughly does it correspond to the filesystem size of the uncompressed .class file?

I've read Jon M开发者_StackOverflowasamitsu, on what PermGen holds:

  • Basic fields of a Java class
  • Methods of a class (including the bytecodes)
  • Names of the classes (in the form of an object that points to a string also in the permanent generation)
  • Constant pool information (data read from the class file, see chapter 4 of the JVM specification for all the details).
  • Object arrays and type arrays associated with a class (e.g., an object array containing references to methods).
  • Internal objects created by the JVM (java/lang/Object or java/lang/exception for instance)
  • Information used for optimization by the compilers (JITs)

The last two may possibly not be relevant to an individual class defintion. I'm interested in the rest.

The only possible approximation I've found is java.lang.instrument.Instrument.getObjectSize(myObject.getClass()); but the "some or all" in the description leaves me less than confident in the accuracy. Any ideas? I feel like I'm overlooking something simple.


The only thing you can do is look at the PermGen size is before and after loading a class, however it continues to use more memory as its methods get (re)compiled.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜