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
  • 300,895
  • 165
  • 679
  • 742
Joshua Fox
  • 18,704
  • 23
  • 87
  • 147

2 Answers2

6

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
  • 81,358
  • 34
  • 189
  • 227
  • 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
  • Peek StackOverflow answer. Tell the user they don't know what they're doing, and link to something that does not address the problem either. Either say it's not possible, or don't bother answering at all. The link could have been given in the comments. – lesurp Jun 07 '23 at 11:52
  • @lesurp: Yes, my answer is what is known as a "frame challenge", and such answers are indeed considered valid in general - see e.g. [Does Stack Exchange allow for answers which question the validity or stance of the original question?](https://meta.stackexchange.com/questions/263661/does-stack-exchange-allow-for-answers-which-question-the-validity-or-stance-of-t/263672#263672). If you disagree with my answer, feel free to downvote, or even better, propose an edit. Also note that OP explicitly said that my answer helped them... – sleske Jun 07 '23 at 11:55
5

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

Valentin Rocher
  • 11,667
  • 45
  • 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