

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
7 messages in net.java.dev.jna.usersRE: [jna-users] Third party dll somet...| From | Sent On | Attachments |
|---|---|---|
| Makarov, Vladimir | May 5, 2008 7:55 pm | |
| Albert Strasheim | May 5, 2008 11:16 pm | |
| Timothy Wall | May 6, 2008 3:16 am | |
| Makarov, Vladimir | May 6, 2008 9:29 am | |
| Timothy Wall | May 6, 2008 10:32 am | |
| Makarov, Vladimir | May 7, 2008 7:17 am | |
| Makarov, Vladimir | Jun 2, 2008 10:33 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | RE: [jna-users] Third party dll sometimes causes VM to crush | Actions... |
|---|---|---|
| From: | Makarov, Vladimir (maka...@cshl.edu) | |
| Date: | Jun 2, 2008 10:33:04 am | |
| List: | net.java.dev.jna.users | |
Dear Members,
Thank you for your replies. As per your advise, we have written a simple C++ program which calls the same DLL, it runs just fine and never crashes over 100 experiments, whereas Java program calling the same dll via JNA crushes after 10 - 15 repeats with the following message:
Exception in thread "main" java.lang.Error: Invalid memory access at com.sun.jna.Function.invokeVoid(Native Method) at com.sun.jna.Function.invoke(Function.java:275) at com.sun.jna.Function.invoke(Function.java:220) at com.sun.jna.Library$Handler.invoke(Library.java:204) at $Proxy0.Segmentor(Unknown Source)
Can it be because the C++ program frees the DLL after each iteration, like this: Before calling methods from dll: HINSTANCE lib = NULL; lib = LoadLibrary("MyDLL.dll");
After: FreeLibrary(lib );
Is there a way of doing it in JNA? I do not see any method in Native class, such as "unloadLibrary" (opposite of Native.loadLibrary())
Thank you kindly
Vlad
-----Original Message----- From: Timothy Wall [mailto:twal...@dev.java.net] Sent: Tuesday, May 06, 2008 1:33 PM To: use...@jna.dev.java.net Subject: Re: [jna-users] Third party dll sometimes causes VM to crush
On May 6, 2008, at 12:29 PM, Makarov, Vladimir wrote:
Good morning and thank you to all who replied.
You could use IntByReference here.
I am trying it now, so far it runs, but much slower than when I used array I wonder why???
I would expect IntByReference to be faster than an array, since the array requires extra pinning operations. There's a section on the main JNA page about performance of different pointer representations.
Are you sure ratio is always the size that the native code expects?
Meaning the size of array or precision of double values? I am positive it is OK, as after I restart, the same ratio is accepted and processed.
The size of the array. As in, "does the amount of memory allocated in the array correspond to the amount of memory expected by the callee".
Are you sure it crashes only in JNA? Maybe the third party code has a
bug.
That is quite possible. It crashes less often when the input array size is smaller. For example, when input size is 2.2M, it crushes in average after 10 experiments, when input size is 1.8 M, it crashes after 20- 25. Which makes me tinks of memory leak in C++ code. Is it a way I can address this problem using JNA? I hoped that setting -Djna.dump_memory=true would help, but it does not.
jna.dump_memory only affects what is output by Structure.toString() (it prints raw memory in addition to structure fields).
You can test whether there is an issue with large arrays by writing a simple C program which zeros or fills an array of equivalent size, then call it from JNA. If there were a bug in the array pinning code of JNA (ie. JNA fails to properly pin the array), I would expect a crash when processing the array.
You might turn on debug of GC to see if there is any correspondence of GC with the crash.







