RFR: 8044107 Add Diagnostic Command to list all ClassLoaders

Staffan Larsen staffan.larsen at oracle.com
Wed May 28 19:46:27 UTC 2014


On 28 maj 2014, at 21:39, Christian Thalinger <christian.thalinger at oracle.com> wrote:

> 
> On May 28, 2014, at 7:50 AM, Staffan Larsen <staffan.larsen at oracle.com> wrote:
> 
>> This change adds a new Diagnostic Command to list all ClassLoaders and some statistics for each classloader. The command is called “GC.classloader_stats” and the information listed is:
>> 
>> * An id for the ClassLoader. This is the pointer to the Klass of the ClassLoader. The reason for using the Klass* (instead of the oop) is that it is stable across invocations.
>> * The id of the ClassLoader’s parent ClassLoader.
>> * The pointer to the ClassLoaderData structure in the VM. This can be useful for debugging.
>> * The number of classes loaded by the ClassLoader.
>> * The total size of all allocated metaspace chunks for the ClassLoader.
>> * The total size of all allocated metaspace blocks for the ClassLoader.
>> 
>> If there are anonymous classes (invokedynamic classes) attributed to the ClassLoader, the following additional information is listed:
>> * The number of anonymous classes loaded by the ClassLoader.
>> * The total size of all allocated metaspace chunks for anonymous classes in the ClassLoader.
>> * The total size of all allocated metaspace blocks for anonymous classes in the ClassLoader.
>> 
>> The information is gathered during a safe point to guarantee that the data structures are consistent. 
>> 
>> I have added a small test and have run this through jprt. A CCC request has been filed.
>> 
>> webrev: http://cr.openjdk.java.net/~sla/8044107/webrev.00/
>> bug: https://bugs.openjdk.java.net/browse/JDK-8044107
>> 
>> Example output:
>> 
>> ClassLoader         Parent              CLData*            Classes   ChunkSz   BlockSz  Type
>> 0x00000007c002d908  0x0000000000000000  0x0000000000000000       0         0         0 sun.misc.Launcher$ExtClassLoader
>> 0x0000000000000000  0x0000000000000000  0x00007fb239c08de0     761   4694016   4241312  <boot classloader>
>>                                                               37     75776     50928   + invokedynamic classes
> 
> You shouldn’t name these “invokedynamic classes”; they can be used for different purposes.  “anonymous classes” is the correct name.

Hmm, yeah. Not a good name, I know. The problem with “anonymous classes” is that for a Java developer, that term is already taken and means something completely different. This is very unfortunate and creates a lot of confusion. My first version called them “lambdas”, but that was even more wrong. Better names are welcome!

/Staffan

> 
>> 0x00000007c0061028  0x00000007c0036878  0x00007fb239c2de60       1      6144      1976 ClassLoaderStatsTest$DummyClassLoader
>>                                                                1      2048      1288   + invokedynamic classes
>> 0x00000007c0036878  0x00000007c002d908  0x00007fb239e10fc0       8     88064     31544 sun.misc.Launcher$AppClassLoader
>> Total = 4                                                      808   4866048   4327048
>> ChunkSz: Total size of all allocated metaspace chunks
>> BlockSz: Total size of all allocated metaspace blocks (each chunk has several blocks)
>> 
>> 
>> Thanks,
>> /Staffan



More information about the hotspot-dev mailing list