I'm trying to create some memory in C++ and access it in Java.
On the C++ side I know that I can use shm_open and mmap to obtain a
memory region and write some data into it. But, how can I open the
memory-mapped file on the Java side? Someone suggested to use MappedByteBuffer
but how can that access the "path" provided to shm_open (it only exists in memory so cannot initialize a File from it). Can I do this without using JNI?
-
The functions you mention seem to indicate a Linux environment. Is that so? Or do you require more portable solution? Anyway, I suggest using more well established interprocess communication. Why not just use sockets.Cheers and hth. - Alf– Cheers and hth. - Alf2016-03-30 04:19:24 +00:00Commented Mar 30, 2016 at 4:19
-
possible duplicate stackoverflow.com/questions/32440527/…BevynQ– BevynQ2016-03-30 04:27:05 +00:00Commented Mar 30, 2016 at 4:27
-
@Cheersandhth.-Alf yes it's linux environment. Doesn't have to be portable. We want to use shared memory for performance reason (to avoid copying).Chao Sun– Chao Sun2016-03-30 04:35:57 +00:00Commented Mar 30, 2016 at 4:35
-
@BevynQ seems like the link you posted doesn't solve my issue. It's also windows based.Chao Sun– Chao Sun2016-03-30 04:36:39 +00:00Commented Mar 30, 2016 at 4:36
Add a comment
|