generating and instantiating many classes at once causing contention

Phil Issler philissler at
Wed Mar 3 10:46:15 PST 2010

We are generating large numbers of small classes and instantiating each one
of them once and only once. It's typically a quick operation.  But when many
threads (more than 16) do this at approximately the same time (within 10-20
milliseconds of each other) we are seeing the threads wait inside native
methods such as getDeclaredMethods0 (which is called by Class.newInstance())
and also in defineClass1 (when the generated bytecode is loaded by our
custom classloader).

Using YourKit, we can't determine if monitors in the native code are
involved or not.  Does anyone have any insight into why this might cause
synchronization in the VM?  Is there easy way around this contention, other
than the obvious answer of generating less code (perhaps a VM setting)?

View this message in context:
Sent from the OpenJDK Hotspot Virtual Machine mailing list archive at

More information about the hotspot-dev mailing list