I am using Java Nativ Access(JNA) calls to access C API. I have defined few few classes, extending com.sun.jna.Structure, correspondent to C structures defined in API.
I am able to make few calls using jna but it started throwing exception on one of the method.

I googled a lot but not finding the proper solution.
I increased heap memory and native method stack of JVM but had no luck.

Please reply me if you have any clue or suggestion.
-Sanjeev

07-05-2011, 04:29 AM

Junky

Try using a profiler to find if/where you have a memory leak.

07-05-2011, 04:43 PM

Sanjeev

Thanks for quick reply.
I used YourKit profiler for finding the memory leak. But I observed strange behaviour; when I run my application with profiler(attached profiler with VM) the out of memory error did not appear and it run without any issue. However, when I run the same application without profiler it is throwing same out of memory error.

It gives me the impression that profiler is some how(by setting some VM arguments) expanding the native memory area that's why it VM is not getting out of memory.

07-05-2011, 07:18 PM

masijade

Well, for one, you do not want to do anything with com.sun.jna.Structure (or nearly any other com.sun class). That class is a Sun JDK/JRE internal class and is subject to change at any time without notice, thereby ruining your program. Find a JNI tutorial and learn how to use JNI properly.