8

I have a command-line executable which I need to run from Java on Windows XP. It uses files as input and output. But I want to avoid the overhead of file IO, so I thought of an in-memory RAM file system.

NetBSD has mount_mfs.

Could you recommend the most convenient way of doing this?

Drew Noakes
  • 284,599
  • 158
  • 653
  • 723
Joshua Fox
  • 17,144
  • 15
  • 75
  • 126

2 Answers2

9

You should also consider whether you really need this (premature optimization, yadda, yadda). On all modern operating systems, filesystem I/O is cached anyway, so frequently-used files are essentially as fast as a RAM disk.

Related question (with many good answers): RAM drive for compiling - is there such a thing?

Community
  • 1
  • 1
sleske
  • 77,633
  • 33
  • 182
  • 219
  • 2
    Good modern file systems with delayed allocation might never hit the disk when you create a short-lifed file. – Joachim Sauer May 26 '09 at 10:08
  • 4
    +1: Can you prove that I/O is the bottleneck? Until you can prove it, don't worry about it. – S.Lott May 26 '09 at 10:21
  • Thanks for that SO link. One thing I learned from there is the right Google search term for the IMFS, namely "RAMDrive" or "RAM Disk". You are probably right about premature optimization, but this info is good to have. – Joshua Fox May 27 '09 at 06:49
6

Commons VFS provides handy interfaces to virtual filesystems, inclunding in-memory file system.

Valentin Rocher
  • 11,521
  • 44
  • 59
  • Thanks, I noted Commons VFS, but does it let me create a new IMFS readable by both Java and an external executable? – Joshua Fox May 27 '09 at 06:33