Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where to find memory-mapped file implementation specifics

Dmitri Bichko
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Can anyone point me to some resources on the actual JVM implementation of memory-mapped files, on both Linux and Windows? My specific question is below, but I would also just like to get a better understanding of how it actual works, and what the platform differences are.

Here's my scenario:

- multiple JVMs read a large data file (using memory mapping)
- these are invoked in a "script-like" fashion, so they are relatively short running
- periodically, a different Java app is run to refresh the data file (the whole file is regenerated)

The whole thing is part of a general (ie not java-specific) job queuing system.

I'm trying to make sure that I (a) implement locking correctly for the updates, and (b) don't unnecessarily duplicate resources. It all sounds very straight-forward, but the Java documentation seems a little sparse (and a lot of stuff is left unspecified). For example, what happens when multiple JVMs map the same (or overlapping) file? I would assume that the paging/caching continues in a reasonable manner, but it'd be nice to be sure.

Another example, an obvious way to do the update:

- generate the new file in a temp location
- if the old file is being used (has read locks), move to temp location
- move new file in its place
- clean out the no longer used temp files on next invocation

Would the memory map survive the underlying file being moved?

As an extra bonus, the data access may be going over NFS (which I understand can affect locking).

I don't need perfect portability - something that works on relatively modern Linux and Win32 (and maybe Solaris) systems is Good Enough. Actually, Win32 support isn't absolutely crucial, would be nice, though.

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic