I previously thought it might be related the garbage collector, which calls the finalize method of DecodeIRCaller class, then the finalize method frees DecodeIR.DLL, and as you noticed, DecodeIR.DLL seems to be gone from the memory. I thouhgt it would go away if I stopped creating/throwing away the instance every time in the loop.
Anyway, I guess I was wrong, and I took a little closer look at the stack dump:
Code: Select all
Stack: [0x03170000,0x031b0000), sp=0x031af8a8, free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0x8bbe7]
C [CaptureIR.dll+0x1fc5]
j DecodeIRCaller.decode([J[I[IILIRSignal;)Z+0
j DecodeIRCaller.decode(LIRSignal;)Z+17
j CaptureIR$monitorThread.run()V+296
...
"DecodeIRCaller.decode([J[I[IILIRSignal;)Z+0" means the DecodeIRCaller.decode method with arguments: [J=long[],
, one more int[], I=int, LIRSignal=class IRSignal, which is the native method implemented in C.
objdump -D CaptureIR.dll shows:
(Note: This is a Unix-style disassembly. Order of operands are reversed from Intel/Microsoft style.)
Code: Select all
CaptureIR.dll: file format pei-i386
Disassembly of section .text:
...
10001f7e <_Java_DecodeIRCaller_decode@28>:
10001f7e: 55 push %ebp
10001f7f: 89 e5 mov %esp,%ebp
10001f81: 81 ec 88 03 00 00 sub $0x388,%esp
10001f87: c7 85 b4 fc ff ff 00 movl $0x0,0xfffffcb4(%ebp)
10001f8e: 00 00 00
10001f91: 8b 45 08 mov 0x8(%ebp),%eax
10001f94: 8b 10 mov (%eax),%edx
10001f96: 8d 85 b8 fc ff ff lea 0xfffffcb8(%ebp),%eax
10001f9c: 89 44 24 10 mov %eax,0x10(%esp)
10001fa0: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
10001fa7: 00
10001fa8: c7 44 24 08 02 00 00 movl $0x2,0x8(%esp)
10001faf: 00
10001fb0: 8b 45 10 mov 0x10(%ebp),%eax
10001fb3: 89 44 24 04 mov %eax,0x4(%esp)
10001fb7: 8b 45 08 mov 0x8(%ebp),%eax
10001fba: 89 04 24 mov %eax,(%esp)
10001fbd: 8b 82 30 03 00 00 mov 0x330(%edx),%eax
10001fc3: ff d0 call *%eax
10001fc5: 83 ec 14 sub $0x14,%esp
10001fc8: 8b 45 08 mov 0x8(%ebp),%eax
10001fcb: 8b 10 mov (%eax),%edx
10001fcd: 8b 45 18 mov 0x18(%ebp),%eax
10001fd0: 89 44 24 04 mov %eax,0x4(%esp)
10001fd4: 8b 45 08 mov 0x8(%ebp),%eax
10001fd7: 89 04 24 mov %eax,(%esp)
10001fda: 8b 82 ac 02 00 00 mov 0x2ac(%edx),%eax
10001fe0: ff d0 call *%eax
10001fe2: 83 ec 08 sub $0x8,%esp
10001fe5: 89 45 e8 mov %eax,0xffffffe8(%ebp)
10001fe8: 83 7d e8 00 cmpl $0x0,0xffffffe8(%ebp)
10001fec: 75 0f jne 10001ffd <_Java_DecodeIRCaller_decode@28+0x7f>
10001fee: c7 85 b0 fc ff ff 00 movl $0x0,0xfffffcb0(%ebp)
10001ff5: 00 00 00
10001ff8: e9 6d 03 00 00 jmp 1000236a <_Java_DecodeIRCaller_decode@28+0x3ec>
...
"[CaptureIR.dll+0x1fc5]" is where it just came back from the call to GetLongArrayRegion, so I guess "[jvm.dll+0x8bbe7]" is somewhere in GetLongArrayRegion itself.
Edit: I previously thought the JVM would be calculating the caller's address, but I guess it's just printing conents of the stack that has the return address. I tried passing null as the first argument to the decode method from the Java code and got the same stack trace. Looks like the DecodeIRCaller instance was finalized (freed) for some reasons even though it is still in use.
I'll try to find something that might cause it. Whatever the case, maybe I should throw a nullpointerexception either here or on the Java side.
Hal