Can't allocate large char array in JNI
- From: CD1 <cristiandeives@xxxxxxxxx>
- Date: Sun, 20 Apr 2008 20:07:48 -0700 (PDT)
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!
.
- Follow-Ups:
- Re: Can't allocate large char array in JNI
- From: Roedy Green
- Re: Can't allocate large char array in JNI
- From: Gordon Beaton
- Re: Can't allocate large char array in JNI
- Prev by Date: Children may show an expression of gratitude for their mothers maternal efforts by presenting to her a luxury watch. A mother who is proud will be able to show this gift at a social group or bridge club as a reminder to others of the wonderful children she has produced.
- Next by Date: Luxury Watches For The Upwardly Mobile
- Previous by thread: Children may show an expression of gratitude for their mothers maternal efforts by presenting to her a luxury watch. A mother who is proud will be able to show this gift at a social group or bridge club as a reminder to others of the wonderful children she has produced.
- Next by thread: Re: Can't allocate large char array in JNI
- Index(es):