I am using Memory Mapped Files to read data from binary file like below but getting error :
Error : Not Enough Storage Is Available To Process This Command.
public void Execute()
{
MemoryMappedFile dataMmf;
dataMmf = MemoryMappedFile.CreateFromFile(Path.Combine(folder, "Data.bin"));
dataStream = dataMmf.CreateViewStream();
BinaryReader reader = new BinaryReader(dataStream, Encoding.UTF8, true);
// Code .......
}
I am working with following application :
Mvc Application
Class Library(MyEngine.dll)
Mvc Application contains MyEngine.dll and i am calling Execute method from my mvc application.
Memory Mapped file requires 64 bit environment to run so i guess when i call Execute method from mvc app,Execute method runs inside web server.
But when i go to properties of my mvc app there i see : Prefer 32 bit option as unchecked and disable
Then why i am getting storage error.This storage error occurs when memory mapped file is run inside 32 bit environment.
MyEngine.dll also have this option as unchecked : Prefer 32 bit
Strange things is i dont get error in case of 100,000 records but when i read 12 millions records then i get error.
On Msdn there is nothing mention about limit that for 32 bit it will read up to this much data.
The way i resolved this error is like below :
But i am trying to understand that why it worked after setting above option only and what i have to do when i will publish this solution on server?
Is there any other way to solve this without setting above option?
Size of data.bin = 448 mb
Stack Trace :
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.MemoryMappedFiles.MemoryMappedView.CreateView(SafeMemoryMappedFileHandle memMappedFileHandle, MemoryMappedFileAccess access, Int64 offset, Int64 size)
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateViewStream(Int64 offset, Int64 size, MemoryMappedFileAccess access)
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateViewStream()