Hi.
Are you checking the return value of shmget and shmat for errors?
I can only check it for shmget - smat returns pointer or -1 in case of
error, which JNA doesn't support.
Does your Java code get pointers at startup and use them throughout the
run, or do the shared memory pointers come and go? A Pointer is effectively
immutable (you have to purposely change its underlying value), so any
"corruption" would have to happen when it's returned from shmat.
I get them at start and use the same pointers during the whole life of the
application. I don't change them anywhere in the app during it's run.
Look at the "corrupted" pointer values to see what they look like. If
there's a pattern, you can check for it and at least throw an exception
before failure.
Ok, I will try to follow your masks advices
You probably need to synchronize the native library accesses in order for
JNA's protected mode to work (it's not intended as a failsafe mechanism but
as a more limited debug tool).
Do you mean I need to ensure thread safety? AFAIK these calls are
thread-safe.
Also, what other high-speed IPC methods could be recommended?
Sockets, but that's more complicated than shared memory.
What about memory-mapped files, do you know how these compare in performance
to shared memory?
It worth mentioning that my operations are one way, I mean the native app
writes the data to shared memory and Java app reads it - there is no need to
sync them.
Thanks for the help.