Any concept of shared memory in Java

Solution 1:

A few ways:

  • RAM Drive
  • Apache APR
  • OpenHFT Chronicle Core

Details here and here with some performance measurements.

Solution 2:

Since there is no official API to create a shared memory segment, you need to resort to a helper library/DDL and JNI to use shared memory to have two Java processes talk to each other.

In practice, this is rarely an issue since Java supports threads, so you can have two "programs" run in the same Java VM. Those will share the same heap, so communication will be instantaneous. Plus you can't get errors because of problems with the shared memory segment.

Solution 3:

Java Chronicle is worth looking at; both Chronicle-Queue and Chronicle-Map use shared memory.

These are some tests that I had done a while ago comparing various off-heap and on-heap options.