How can I know Where and how is the memory behind the retrurned char
* allocated ?
Regards,
Le 18 mai 09 à 16:01, Timothy Wall a écrit :
Where and how is the memory behind the returned char* allocated?
The memory behind each of the Java String parameters is only valid
for the duration of the native call.
On May 18, 2009, at 9:40 AM, Sylvain ZUNINO [GMAIL] wrote:
Hello,
I implemente JNA to call a C function which return a char *.
public interface MYCFunction extends Library {
MYCFunction INSTANCE = (MYFunction)Native.loadLibray
(JNA_LIB_PATH, MYCFunction.class);
String cfunction(String param1, String parm2, String[]param3, int
nbOfParams3);
}
I call more than 10000 times this function in a program :
for (int i=0; i<15000; i++) {
String param1= "param1";
String param2= "param2";
String[] param3= { "param3_1", "param3_2" };
String res = MYCFunction.INSTANCE.cfunction(param1, param2,
param3, param3.length);
........
}
My C program work well when I try It with a main (15000 times no
problems).
But when I test with JNA I'have a JVM crash at the 9998 or 10003
iterations.
What I'm wrong ???