2008/8/23 Timothy Wall <twal...@dev.java.net>:
all arrays as pinned, since Get*ArrayCritical locks the GC until the
corresponding Release*ArrayCritical is called - v.bad for native
methods that might block.
Other than the obvious aspect of the array itself being GC'd, why would a
pinned primitive array interfere with GC?
From what I understand, pinning an array globally disables the GC
until all arrays are unpinned. So, if you use
GetPrimitiveArrayCritical, and pass the resulting pointer to a
function that blocks, the GC won't run, and memory allocations on
other threads might block.
Ergo, using GetPrimitiveArrayCritical by default would be bad, since
we have no idea what the native code is going to do. It should only
be used when the native function is guaranteed not to block - e.g.
only doing memory copy, rendering from in-memory data, etc. Anything
that might need to access an external resource like a file or a socket
would be bad.