I'm using a memory mapped file that is approx. 100 GB of data. When I call CreateViewStream
on that file it takes 30 minutes to create it and seems that it's because of the size of the memory mapped file but, why does take it so long?
Does it copy the whole file into managed memory?
It takes much longer when I write the file with a file stream and access it without a reboot. (strangely)
I'm unable to replicate these issues. Here's the code I used to test:
static void Main(string[] args)
{
var sw = Stopwatch.StartNew();
var mmf = MemoryMappedFile.CreateFromFile(@"f:\test.bin");
var stream = mmf.CreateViewStream();
for (int i = 0; i < 100000; i++)
{
stream.ReadByte();
}
Console.WriteLine(sw.Elapsed);
}
f:\test.bin
is a 100GB zero filled file that I generated for the purposes of this test. I'm able to create the MemoryMappedFile
, then run CreateViewStream
and read 100,000 bytes from it in 3.7s.
Please provide sample code that's exhibiting the behavior you've described and I'll be glad to pick it apart and see what's going on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With