Get<PrimitiveType>ArrayElements
family of functions are documented to either copy arrays, or pin them in place (and, in so doing, prevent a compacting garbage collector from moving them). It is documented as a safer, less-restrictive alternative to GetPrimitiveArrayCritical
. However, I'd like to know which VMs and/or garbage collectors (if any) actually pin arrays instead of copying them.
Older IBM JVMs pinned (1.4 and before - ie: NOT the current IBM J9 JVM) but since then, they have not. In general, JVMs don't like pinning as it really messes up copying garbage collectors, which is what most production JVMs do today. I'm not 100% up to date (ie: latest Java 7 builds), but historically HotSpot didn't either (for the same generational GC reasons).
Be aware: a JVM that pins today might not tomorrow, and vice versa, so you need to write your code to handle it both ways, just like the base Java libraries do.
Shenandoah supports pinning (although it is not clear if it does so when using Get*ArrayElements
or only when Get*Critical
): https://shipilev.net/jvm-anatomy-park/9-jni-critical-gclocker/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With