Processing a Big File Using Memory-Mapped Files

In an earlier section, I said I would tell you how to map a 16-EB file into a small address space. Well, you can’t. Instead, you must map a view of the file that contains only a small portion of the file’s data. You should start by mapping a view of the very beginning of the file. When you’ve finished accessing the first view of the file, you can unmap it and then map a new view starting at an offset deeper within the file. You’ll need to repeat this process until you access the complete file. This certainly makes dealing with large memory-mapped files less convenient, but fortunately most files are small enough that this problem doesn’t usually come up.

Let’s look at an example using an 8-GB file ...

Get Windows® via C/C++, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.