RFR: 8044107 Add Diagnostic Command to list all ClassLoaders

Staffan Larsen staffan.larsen at oracle.com
Fri May 30 06:36:11 UTC 2014


Leaving the naming behind for a moment. Any thoughts on the rest of the code?

/Staffan

On 28 maj 2014, at 22:26, Remi Forax <forax at univ-mlv.fr> wrote:

> 
> On 05/28/2014 09:51 PM, Coleen Phillimore wrote:
>> 
>> On 5/28/14, 3:49 PM, Christian Thalinger wrote:
>>> On May 28, 2014, at 12:46 PM, Staffan Larsen <staffan.larsen at oracle.com> wrote:
>>> 
>>>> 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!
>>> These classes are defined via:
>>> 
>>>     public native Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches);
>>> 
>>> so this is what they are called.  Sorry :-)
>> 
>> It's still a bad name.  I call them jsr292-anonymous classes. maybe "unsafe anonymous classes" ?
>> 
>> Coleen
> 
> John Rose has coined the name 'anonymous klasses' which is not that bad.
> 
> Rémi
> 
>>> 
>>>> /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