1

Closed

Error on retrive memory mapped file with threadpool access.

description

Mikael,
 
I have emailed to you in code project about the issue I discovered when I use access MMF from different threads and you suggest me to try with new release in codeplex However, I got similar issues as following when I use Array<T> class. I am not sure the following error message is enough for you to debug, if you need I can prepare a solution to reproduce this issue. Thanks
 
A first chance exception of type 'Winterdom.IO.FileMap.FileMapIOException' occurred in Winterdom.IO.FileMap.dll
I/O error occurred. (-2147024888)
at Winterdom.IO.FileMap.MemoryMappedFile.MapView(MapAccess access, Int64 offset, Int64 size) in C:\Download\mAdcOW.DataStructures-src\Release\Winterdom.IO.FileMap\MemoryMappedFile.cs:line 320
at Winterdom.IO.FileMap.MapViewStream.MapView(Int64& viewStartIdx, Int64& viewSize) in C:\Download\mAdcOW.DataStructures-src\Release\Winterdom.IO.FileMap\MapViewStream.cs:line 92
at Winterdom.IO.FileMap.MapViewStream.Seek(Int64 offset, SeekOrigin origin) in C:\Download\mAdcOW.DataStructures-src\Release\Winterdom.IO.FileMap\MapViewStream.cs:line 231
at Winterdom.IO.FileMap.MapViewStream..ctor(MemoryMappedFile backingFile, Int64 mapSize, Boolean isWriteable) in C:\Download\mAdcOW.DataStructures-src\Release\Winterdom.IO.FileMap\MapViewStream.cs:line 134
at Winterdom.IO.FileMap.MemoryMappedFile.MapAsStream() in C:\Download\mAdcOW.DataStructures-src\Release\Winterdom.IO.FileMap\MemoryMappedFile.cs:line 335
at mAdcOW.DataStructures.ViewManager.AddNewViewToThreadPool(Int32 threadId) in C:\Download\mAdcOW.DataStructures-src\Release\mAdcOW.DataStructures\ViewManager.cs:line 108
at mAdcOW.DataStructures.ViewManager.GetView(Int32 threadId) in C:\Download\mAdcOW.DataStructures-src\Release\mAdcOW.DataStructures\ViewManager.cs:line 55
at mAdcOW.DataStructures.Array1.Read(Int64 index) in C:\Download\mAdcOW.DataStructures-src\Release\mAdcOW.DataStructures\Array.cs:line 185
at mAdcOW.DataStructures.Array
1.get_Item(Int64 index) in C:\Download\mAdcOW.DataStructures-src\Release\mAdcOW.DataStructures\Array.cs:line 230
Closed Feb 8, 2010 at 6:33 AM by Wobba

comments

Wobba wrote Jan 25, 2010 at 11:24 AM

I suspect you are running on 32bit. Read the forum thread at http://mmf.codeplex.com/Thread/View.aspx?ThreadId=75328 regarding the same error. (-2147024888 = 80070008).

The problem is that I have optimized it for 64bit, allocating new views for the whole file for each thread since 64bit has a vast address space available. I will make it work for 32bit as well with smaller pages in the .Net 4.0 version I'm planning.

kevin7806 wrote Jan 25, 2010 at 4:19 PM

Do you have any idea of error code -2147024896 when I am calling following block and received last Win 32 error
public IntPtr MapView(MapAccess access, long offset, long size)
    {
        if (!IsOpen)
            throw new ObjectDisposedException("Gexa.Business.Market.Solution.MemoryMappedFile.MapView - MMF already closed");

        IntPtr baseAddress = IntPtr.Zero;
        IntPtr mapSize = new IntPtr(size); // sws note Throws OverflowException if (a) this is a 32-bit platform AND (b) size is out of bounds (ie. int bounds) with respect to this platform

        baseAddress = Win32MapApis.MapViewOfFile(
          _hMap, (int)access,
          (int)((offset >> 32) & 0xFFFFFFFF),
          (int)(offset & 0xFFFFFFFF), mapSize
          );

        if (baseAddress == IntPtr.Zero)
        {
            throw new FileMapIOException(Marshal.GetHRForLastWin32Error());
        }

        return baseAddress;
    }

Wobba wrote Jan 25, 2010 at 5:44 PM

Kevin, could you provide me with some code samples in order to reproduce the errors you are seeing? You can upload files with your comment.

wrote Jan 25, 2010 at 7:41 PM

wrote Jan 27, 2010 at 8:48 AM

Wobba wrote Feb 8, 2010 at 6:30 AM

Not able to reproduce, so I'm closing the issue, in accordance with the reporter.

wrote Feb 8, 2010 at 6:33 AM

wrote Feb 14, 2013 at 12:12 AM

wrote May 16, 2013 at 5:36 AM