开发者

UnknownError_Num 8: MemoryMappedFile

开发者 https://www.devze.com 2023-03-18 12:52 出处:网络
I\'m having trouble using the MemoryMappedFile using the following code. static int NoOfChannels = 1164;

I'm having trouble using the MemoryMappedFile using the following code.

    static int NoOfChannels = 1164;
    static int NoOfRows = 64;
    static int N = NoOfChannels * NoOfRows;
    static int NoOfProjections = 10000;
    static long val = (long)NoOfChannels * NoOfRows * NoOfProjections * 4;
    static FileStream stream = null;

    stream = new FileStream("D:\\TEST.DAT", FileMode.Open,开发者_如何学运维 FileAccess.ReadWrite, FileShare.ReadWrite, 10);
        stream.SetLength(val);

MemoryMappedFile m = MemoryMappedFile.CreateFromFile(stream, "XXXX", stream.Length,    MemoryMappedFileAccess.ReadWrite, null, HandleInheritability.None, true);

        for (int i = 0; i < NoOfProjections; i++)
        {
            long Pos = (long)(i * N * 4);

            MemoryMappedViewStream s = m.CreateViewStream(Pos, N * 4);
        }

Using this code result in an error UnknownError_Num 8. If I limit NoOfChannels to a smaller value, there is no error. I have 32GB in my system, so there should be no problem allocating this amopunt of data.

Has someone every experienced such a behaviour?

Thanks Martin

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号