performance impact of JNI GetCritical*
linuxhippy at gmail.com
Thu Mar 18 17:20:20 UTC 2010
> How optimized are the Get/ReleasePrimitiveArrayCritical JNI functions?
> Do they disable GC or do they only pin the array at the specific address?
For moving gc's they actually stop the whole GC process as long as all
arrays are released by ReleasePrimitiveArrayCritical.
So basically the cost is some thread-synchronization (to make the gc
know on all threads not to run now), plus the impact on the GC. So for
small arrays theres quite high overhead.
CMS itself is non-moving (old gen) so basically there could be some
optimizations, but no idea wether this is actually done.
> lets say I have a short java array of length 12. Should I copy it to a
> direct NIO buffer and use the buffer as vehicle, use Get/ReleaseCritical
> or something else?
For very short arrays this is quite likely beneficial (at least if
you're on JDK7, at least older JDK6 releases do get/releasecritical +
memcpy in jni code).
Just to be curious, whats your actual usecase?
hotspot-gc-use mailing list
hotspot-gc-use at openjdk.java.net
More information about the hotspot-gc-dev