1

I use boost latest version 1.6.0 and Visual studio 2015. mapped_file_source throw exception when file size bigger than 500MB.

the exception said "failed mapping view: The parameter is incorrect. : iostream stream error"

How can i open bigger than 500MB file?

that's my code here.

bool CompareFile(path file1, path file2)
    {
        try {
            boost::iostreams::mapped_file_source f1(file1);
            boost::iostreams::mapped_file_source f2(file2);
            if (std::memcmp(f1.data(), f2.data(), f1.size()))
                return false;
            else
                return true;
        }
        catch (const std::exception& e)
        {
            e.what();
            return false;
        }
        catch (...)
        {
            return false;
        }
    }
user3451580
  • 31
  • 1
  • 5
  • Is that a 32bit application? – Dan Mašek May 30 '16 at 12:07
  • Yes 32bit Application – user3451580 May 30 '16 at 12:07
  • 2
    In that case it's very likely you're running out of address space. To map each file you need a continuous address range of same size as the file. It's probably the second file that breaks it. Switch to 64bit, or just don't map the whole thing at once. – Dan Mašek May 30 '16 at 12:17
  • @DanMašek How can partition big file division for memory map? could you show some example? – user3451580 May 30 '16 at 14:48
  • You can specify [size and offset](http://www.boost.org/doc/libs/1_61_0/libs/iostreams/doc/classes/mapped_file.html) as parameters of the constructor as well as the `open()` method. Pick some size, and then change the offset in a loop, processing one block at a time. Don't forget to handle the size of the last block correctly, it most likely won't be full-size. – Dan Mašek May 30 '16 at 21:47

0 Answers0