FileMap now on GitHub
After a few years, people still ask about my old FileMap library, a .NET wrapper for the Memory Mapped Files Win32 API, and I get occasional bug reports about it. It’s hard to believe I wrote the original code over 5 years ago!
Anyway, I’ve now cleaned up the code (alongside some of those fixes), and posted it to a GitHub repository as well. I’ve now updated the code to Visual Studio 2008 and cleaned up the unit tests.






Hi Tomas,
I was wondering whether FileMap would help me achieve the following: I have 2 apps: App_Collector collects data and writes a 60Kb csv file to disk every 3 minutes. The second app, App_Displayer, displays the data stored in the files. App_collector runs all the time, but App_Displayer does not, and when App_Displayer starts up it needs to read the 144 most recently stored csv files in order to display what it needs to. App_Displayer takes several minutes to read and process the 144 files, which is way too long. If App_Collector stored the most recent 144 files in memory, could FileMap be used so that App_Displayer could get the data directly from App_Collector, in much less time than reading the data from csv files on the disk?
Regards,
Peter
You could certainly do that, though you’d need to write some extra control information into memory so that the reader could figure out where each one begins and ends. However, I’m not sure how “easy” it would be to get working reliably given how you’d need to basically allocate a big chunk of shared memory and then handle it as some sort of circular buffers (so you’d need to do some serious interprocess synchronization to avoid the writer and reader stepping on each others toes).
Thanks for your reply Tomas. I will take a look and let you know what I come up with. The easy part is that Collector only writes and Displayer only reads. I will use a mutex for IPC synchronization.
Did you see that .NET (Beta 2) has a System.IO.MemoryMappedFiles which seems to contain all the memory mapped file io classes/calls one would need, but I cannot wait until 4.0 is released, a pity.