In my simulation code, I use boost memory mapped files to allocate arrays of large numbers to disk.
It works well, but I could not find a way to detect a situation in which I allocate an array that has more free disk space. For example, the following code will execute happily (provided that I have less than 8E9 bytes of free space on the HDD):
boost::iostreams::mapped_file_params file_params;
file_params.path = path;
file_params.mode = std::ios::in | std::ios::out;
file_params.new_file_size = static_cast<size_t>(8E9); # About 10GB
file_params.length = static_cast<size_t>(8E9);
boost::iostreams::mapped_file result;
result.open(file_params);
I can even work with resuld.data()until I write the part of the memory that was not allocated (due to lack of space on the HDD), and then I get the following error:
memory access violation at address: 0x7e9e2cd1e000: non-existent physical address
Is there a way to detect this error before I get a cryptic memory access violation?
: , avilable , , , ( , , ).
std:fill , memory access violation, . - .