memory allocating /deallocating in jni

1. the jni code looks like this:

char * x = malloc(10);

jstring y = env->newStringUTF(x);

//free(x)?

return y;

//back to java

should I use free(x) after i have created jstring from it?

or does java pin out the memory of x to y (not copying it) so freeing it will cause damage to jstring object y.

2.good jni book

[385 byte] By [veazy] at [2007-9-26 14:24:58]
# 1
1. Why don't you just run a test and see what happens.2. OK Book - I don't think there are any great ones:Essential JNI - Rob Gordon
bschauwe at 2007-7-2 16:07:16 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
>should I use free(x) after i have created jstring from it?Definitely.Java manages its own data space.
jschell at 2007-7-2 16:07:16 > top of Java-index,Java HotSpot Virtual Machine,Specifications...