本文介绍了哪些VM或GC支持JNI固定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Get<PrimitiveType>ArrayElements函数族可以记录为复制数组或将它们固定在适当的位置(并且这样做可以防止压缩的垃圾收集器移动它们).它被记录为GetPrimitiveArrayCritical的更安全,限制更少的替代方法.但是,我想知道实际上是哪些VM和/或垃圾收集器(如果有的话)固定阵列,而不是复制它们.

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.

推荐答案

固定了较旧的IBM JVM(1.4及之前的版本-即:不是当前的IBM J9 JVM),但此后一直没有.通常,JVM不喜欢固定,因为它确实使复制垃圾收集器变得混乱,这是当今大多数生产JVM所做的事情.我不是100%处于最新状态(即:最新的Java 7版本),但是从历史上看,HotSpot都不是(出于相同的GC世代原因).

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).

请注意:今天固定的JVM可能不会在明天出现,反之亦然,因此您需要编写代码来以两种方式处理它,就像基础Java库一样.

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.

这篇关于哪些VM或GC支持JNI固定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 15:04