Re: Shared memory IPC using NIO memory-mapped files -- anyone done this?

Bob Lee <[email protected]>
Newsgroups gmane.comp.windows.devel.java.advanced
Message-ID <[email protected]>
Memory mapped files are not the way to got about this. Having to write
everything to disk would kind of kill your "high performance" requirement.
:)

You'll need JNI code which wraps unix domain sockets. If that isn't fast
enough, wrap true shared memory with JNI. Use shared memory to actually
share the data and the sockets to coordinate between processes.

I would start off with network sockets. If those aren't fast enough, they'll
be easy enough to replace w/ domain sockets (the native API is identical).

Bob

On 8/18/07, Brian Maso <[email protected]> wrote:
>
> Java NIO supports memory-mapped files, which has the cool ability to
> allow multiple apps to share the same array of data if they all map
> the same file in to their respective address spaces.
>
> I've wondered about using memory-mapped files for inter-process
> communication for a while. Someone I know is asking me whether or not
> this is good to use for high-performance communication between Java
> and C++ -- basically sharing fixed-length records between Java and a
> C/C++ program in a producer/consumer sort of system.
>
> It seems like memory-mapped files would be ideal for sharing data
> like this. A Java app could extract data from some source and put it
> in to a MappedByteBuffer, which would immediately be visible to any
> other app on the same box that has mapped the same file. However, I
> can't figure out how the Java process would "signal" the external
> app, indicating that a new record is available for consumption, or
> alternatively how an external app would signal the Java app to tell
> it to write out a new record to the shared memory space.
>
> Anyone familiar with shared memory inter-process communication out
> there who can give me a hint? Google and the regular sources aren't
> revealing anything to me this morning.
>
> Brian Maso
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.