I have a C++ piece of code that creates shared memory. Is it possible to write Java Code which can read the memory created by the C++ code unless using JNI. By the way I am using Windows OS.
In order to maximize the performance of your Java applications, InterSystems IRIS offers a Java shared memory connection. A shared memory connection allows both the client and the database to share the same memory on their host machine. This shared memory is temporary, and it is backed up by virtual memory.
Two functions shmget() and shmat() are used for IPC using shared memory. shmget() function is used to create the shared memory segment, while the shmat() function is used to attach the shared segment with the process's address space.
So, shared memory provides a way by letting two or more processes share a memory segment. With Shared Memory the data is only copied twice – from input file into shared memory and from shared memory to the output file. SYSTEM CALLS USED ARE: ftok(): is use to generate a unique key.
See MappedByteBuffer
. It's the standard Java class to read & write shared memory. I use it a lot. Yes, you can use this to communicate with any program written in any language which uses shared memory, and it's all very standard Java, no JNI.
Yes, you can use code project :code project
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With