Friday, May 31, 2013

Memory Mapped File Quirks [Greg] - BCL Team Blog - Site Home - MSDN Blogs

Memory Mapped File Quirks [Greg] - BCL Team Blog - Site Home - MSDN Blogs:
Recall that when you create a view of a memory mapped file, Windows aligns the view to virtual memory page boundaries. E.g., if your page size is, say, 4096 bytes, a memory-map view can only be 4096, 8192, 12288, ..., N × 4096 bytes large.
As our data file is smaller than a memory page, we get a view that is as large as a memory page (if the size of virtual memory pages on your machine is not 4096, then the output will also differ accordingly). The memory-map view contains the data supplemented with zeros. When we use a stream reader to read this data, we only reach the EOF mark when we get to the end of the entire view, not to the end of the original data.

No comments: