views:

371

answers:

1

I'd like to know if anyone tried new .NET 4.0 Memory Mapped Files features? I know that they are as old as OS but native handling in .NET is new.

Has anyone been able to test this and say something about performance? I'm quite interested in access time to random parts of binary file, write speed and so on. Also performance comparsion to native WinAPI MMF would be nice.

Thanks!

+4  A: 

Memory mapped files in .NET 4.0 (in the new System.IO.MemoryMappedFiles namespace) simply wrap the Win32 API for memory mapped files.

That means they are as fast as is possible. This is the same mechanism that is used to load .NET assemblies into memory.

In terms of actual timing numbers, this will depend on 32bit versus 64bit, how much memory you have, how large the files are, the access pattern(s) and to a large extent the type of physical disk hardware.

Ref: Memory-Mapped Files

Mitch Wheat
thanks, I know this reference, more accurate for this question should be this link: http://msdn.microsoft.com/en-us/library/ms810613.aspx (it was on page you mentioned). I think, I'll do some test cases myself and post results here. But, maybe someone already had them done?
michajas
"But, maybe someone already had them done?" - the actual numbers will depend on quite a few factors, mentioned above, which is presumably why there is not a standard benchmark available.
Mitch Wheat
I know about these factors, but I'm not thinking about standardized benchmark, but results with complete test case (hardware etc.). It would be best if these were compared with other methods like FileStream etc.I ask about this because I'm going to have work with large files (over 10GB) and reading random data from them. I want to know that MMF is the best choice :)
michajas