Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do those strange class names in a java heap dump mean?

I'm trying to track down a memory leak in a java process, using jmap and jhat. Every time I do this I see those weird notation for specific object types, like [S for string arrays and [C for Character arrays. I never remember what means what, and it's very hard to google this stuff.

(EDIT: to prove my point, it turns out that [S is array of short and [C is array of char.)

Anyone care to make a table listing all the different class names and what they mean? Or point me to such table?

Specifically I'd like to know what [Ljava.lang.Object; means.

like image 223
itsadok Avatar asked Jul 06 '09 14:07

itsadok


People also ask

What does a heap dump contain?

Heap dumps contain a snapshot of all the live objects that are being used by a running Java™ application on the Java heap. You can obtain detailed information for each object instance, such as the address, type, class name, or size, and whether the instance has references to other objects.

How do I get rid of heap dump on memory error?

In order to capture a heap dump automatically, we need to add the HeapDumpOnOutOfMemoryError command-line option that generates a heap dump when a java. lang. OutOfMemoryError is thrown.

How do I get rid of a heap dump of running?

Right-click on one of the Java process. Click on the 'Heap Dump' option on the drop-down menu. Heap dump will be generated. File path where heap dump is generated will be specified in the Summary Tab > Basic Info > File section.


2 Answers

You'll find the complete list documented under Class.getName():

If this class object represents a reference type that is not an array type then the binary name of the class is returned, as specified by the Java™ Language Specification, Second Edition.

If this class object represents a primitive type or void, then the name returned is a String equal to the Java language keyword corresponding to the primitive type or void.

If this class object represents a class of arrays, then the internal form of the name consists of the name of the element type preceded by one or more '[' characters representing the depth of the array nesting. The encoding of element type names is as follows:

 Element Type        Encoding boolean             Z byte                B char                C class or interface  Lclassname; double              D float               F int                 I long                J short               S  
like image 79
kdgregory Avatar answered Oct 07 '22 19:10

kdgregory


it is an array of objects as specified by JVM Specifications for internal representation of class names:

  • a single [ means an array of
  • L followed by a fully qualified class name (e.g. java/lang/Object) is the class name terminated by semicolon ;

so [Ljava.lang.object; means Object[]

like image 26
dfa Avatar answered Oct 07 '22 19:10

dfa