16 messages in net.java.dev.jna.usersRe: [jna-users] Crash JVM call functi...
FromSent OnAttachments
Sylvain ZUNINO [GMAIL]May 18, 2009 6:40 am 
Timothy WallMay 18, 2009 7:00 am 
Sylvain ZUNINO [GMAIL]May 18, 2009 7:46 am 
Sylvain ZUNINO [GMAIL]May 18, 2009 9:56 am 
Timothy WallMay 18, 2009 10:04 am 
Sylvain ZUNINO [GMAIL]May 18, 2009 10:14 am 
Timothy WallMay 18, 2009 11:00 am 
Sylvain ZUNINO [GMAIL]May 18, 2009 11:43 am 
Sylvain ZUNINO [GMAIL]May 18, 2009 11:50 am 
Timothy WallMay 18, 2009 12:02 pm 
Sylvain ZUNINO [GMAIL]May 18, 2009 12:34 pm 
Timothy WallMay 18, 2009 12:37 pm 
Sylvain ZUNINO [GMAIL]May 19, 2009 12:33 am 
Timothy WallMay 19, 2009 1:27 am 
Sylvain ZUNINO [GMAIL]May 19, 2009 1:35 am 
Timothy WallMay 19, 2009 2:18 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Crash JVM call function many timesActions...
From:Sylvain ZUNINO [GMAIL] (sylv@gmail.com)
Date:May 18, 2009 7:46:20 am
List:net.java.dev.jna.users

Sorry,

But I'm a beginner and I forget to tell you that It works on Windows architecture 32 bits but doesn't work on linux amd64 kernel. I tried to change my CFunction like that : void cfunction(String param1, String parm2, String[]param3, int nbOfParams3, byte[] out_param);

But I've the same problem... Concerning the memory ... I'm sorry but I dont know answer your question ...

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 ???