java - What's the trade-off between using GetPrimitiveArrayCritical and Get ArrayRegion? -
When bridging c ++ and java using JNI, we always want to avoid unnecessary copying. I got GetPrimitiveArrayCritical After making the call, the original code should not run for an extended period of time Before this release, the Pyrametic Array Critical Code of Code, within this pair of work, as we walk in "important area" Treatment Ahia. Inside an important area, the original code should not call other JNI functions, or any system call which may cause the current thread to wait for another Java thread . (For example, the current thread should not be called to read on the stream written by any other Java thread.) With these restrictions it is more likely that the original code is one of the Orange Will receive the exact version , even if VM does not support pinning. My questions are: Extended period of time Does this mean that we can safely call other JNI functions or system calls which will not cause the current thread to block and wait, is another Java thread? Is GetPrimitiveArrayCritical thread-safe? Should I know something when using GetPrimitiveArrayCritical instead of GetArrayRegion The key to understanding here is that you have a significant segment (such as a lock) on this piece of memory. The extended period of time indicates that once you catch this lock, you can stop JVM from doing normal things. Are there. So you should do the resources you need to do as soon as possible. You definitely do not want to leave an operation that could block, for example, as you would completely stop the system. Go with it because I've locked it up that the main thing that lock prevents the garbage collection, but the documentation is quite clear that it's the behavior of calling other JNI tasks Does not support So you think that your code works in a version of JVM and not others. Because it is receiving a lock (serious stream), yes, this thread is safe because it is a lock, you can see it too long (see 1) Should not be kept. GetArrayRegion will always give you a copy, GetPrimitiveArrayCritical may give you a copy or may direct you to The indicator is not sure that the reason for this is that the GVM Implementor directly avoids pointers and gives the future flexibility, if they greatly affect the normal VM performance (i.e. to allow locking on some garbage collectors Very much for May have an impact). GetPrimitiveArrayCritical can not give us an opportunity to copy the array, but I can not fully understand the document of its restriction:
Comments
Post a Comment