The function convertToLittleEndian [1] may leave scope (line 1822) without JNI releasing array elements. This could impact GC efficiency. 1804 * Convert an array in big-endian byte order into little-endian byte order. 1805 */ 1806int convertToLittleEndian(JNIEnv *env, jbyteArray source, jbyte* destination, 1807 int destinationLength) { 1808 1809 int sourceLength = env->GetArrayLength(source); 1810 1811 jbyte* sourceBytes = env->GetByteArrayElements(source, 0); 1812 if (sourceBytes == NULL) { 1813 return -1; 1814 } 1815 1816 int copyLen = sourceLength; 1817 if (sourceLength > destinationLength) { 1818 // source might include an extra sign byte 1819 if (sourceLength == destinationLength + 1 && sourceBytes[0] == 0) { 1820 copyLen--; 1821 } else { ==> 1822 return -1; 1823 } 1824 } 1825 1826 // Copy bytes from the end of the source array to the beginning of the 1827 // destination array (until the destination array is full). 1828 // This ensures that the sign byte from the source array will be excluded. 1829 for (int i = 0; i < copyLen; i++) { 1830 destination[i] = sourceBytes[sourceLength - 1 - i]; 1831 } 1832 if (copyLen < destinationLength) { 1833 memset(destination + copyLen, 0, destinationLength - copyLen); 1834 } 1835 1836 env->ReleaseByteArrayElements(source, sourceBytes, JNI_ABORT); 1837 1838 return destinationLength; 1839} 1840 [1] http://hg.openjdk.java.net/jdk/jdk/file/71c04702a3d5/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp#l1822