

![]() | 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: |
3 messages in net.java.dev.jna.users[jna-users] Exception in JNA finalizer| From | Sent On | Attachments |
|---|---|---|
| Yury Kudryashov | Apr 23, 2009 7:08 am | |
| Timothy Wall | Apr 23, 2009 10:45 am | |
| Yury Kudryashov | Apr 24, 2009 12:54 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: | [jna-users] Exception in JNA finalizer | Actions... |
|---|---|---|
| From: | Yury Kudryashov (kudr...@gmail.com) | |
| Date: | Apr 23, 2009 7:08:23 am | |
| List: | net.java.dev.jna.users | |
Hi,
I'm using a proprietary DLL via JNA. All works great except for a single problem described below.
The DLL communicates with the remote server and allows retrieving huge list of entitites (more than 75000, each is about 350 bytes of size in C). The API is like this: there is a method to get the number of entities:
INT WINAPI countEntities(PINT count)
and the other one to get an entity by index:
INT WINAPI getEntity(int index, EntityStructPtr s);
where EntityStructPtr is a pointer to a complex structure.
I have mapped these functions and the structure to JNA ok, everything works fine with small data sets and when I use a test DLL (that provides the same interface). But when it comes to real DLL, I get JVM crashes with the following:
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x775059c3, pid=3304, tid=3612
Stack trace is:
Stack: [0x1f320000,0x1f370000], sp=0x1f36f780, free space=317k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [ntdll.dll+0x659c3] C [ntdll.dll+0x65883] C [kernel32.dll+0x4c56f] C [msvcrt.dll+0x9d6b] C [jna7098527778289589434.tmp+0x6012] j com.sun.jna.Memory.free(J)V+0 j com.sun.jna.Memory.finalize()V+13 v ~StubRoutines::call_stub
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j com.sun.jna.Memory.free(J)V+0 j com.sun.jna.Memory.finalize()V+13 v ~StubRoutines::call_stub j java.lang.ref.Finalizer.invokeFinalizeMethod(Ljava/lang/Object;)V+0 j java.lang.ref.Finalizer.runFinalizer()V+45 j java.lang.ref.Finalizer.access$100(Ljava/lang/ref/Finalizer;)V+1 j java.lang.ref.Finalizer$FinalizerThread.run()V+11 v ~StubRoutines::call_stub
The crashes occur not immediately, but after some number of entities are retrieved ok. It seems that this error happens when JNA tries to free memory for the structures passed to getEntity. I do not use them and it seems they should be GCed ok.
I tried to find a workaround and tried to store references to the structures to avoid GC - but this soon leads to OutOfMemory errors (although almost all entities are loaded ok).
Looking forward to any ideas.
Thank you. Yury Kudryashov.







