C
CD1
Hi there!
I'm trying to allocate a char array using JNI, but when the length is
too big it doesn't work! My char array is a representation of an
image, and its size is the width * height * 3 characters, so it
usually goes beyond 1 MB. My code works with smaller images, but when
the array size is bigger than 718832 (don't know why this is the
maximum value), the JVM crashes and it returns 134 as the exit code.
My code is like this:
// the variables are JNIEnv *env, int length, jchar *value, jmethodID
char_array_fid
jcharArray jchar_array = (*env)->NewCharArray(env, length);
if (jchar_array == NULL) {
return;
}
(*env)->SetCharArrayRegion(env, jchar_array, 0, length, value); // !!!
(*env)->SetObjectField(env, obj, char_array_fid, jchar_array);
By using printfs, I've found out the JVM crashes when it calls the
function SetCharArrayRegion, but only if the length is greater than
718832. And if I modify the length value to something like 1000, this
exact code works fine.
Any help would be appreciated
See ya!
I'm trying to allocate a char array using JNI, but when the length is
too big it doesn't work! My char array is a representation of an
image, and its size is the width * height * 3 characters, so it
usually goes beyond 1 MB. My code works with smaller images, but when
the array size is bigger than 718832 (don't know why this is the
maximum value), the JVM crashes and it returns 134 as the exit code.
My code is like this:
// the variables are JNIEnv *env, int length, jchar *value, jmethodID
char_array_fid
jcharArray jchar_array = (*env)->NewCharArray(env, length);
if (jchar_array == NULL) {
return;
}
(*env)->SetCharArrayRegion(env, jchar_array, 0, length, value); // !!!
(*env)->SetObjectField(env, obj, char_array_fid, jchar_array);
By using printfs, I've found out the JVM crashes when it calls the
function SetCharArrayRegion, but only if the length is greater than
718832. And if I modify the length value to something like 1000, this
exact code works fine.
Any help would be appreciated
See ya!