Reputation: 685
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?
Upvotes: 4
Views: 1933
Reputation: 171
On Linux environment shared memory has special memory segment:
/dev/shm
Name provided in shm_open (e.g. "elo320") is used to create file
/dev/shm/elo320
This path can be used in Java.
Upvotes: 2