MemoryMappedViewAccessor.SafeMemoryMappedViewHandle
denotes the virtual memory page the respective part of the file is mapped to. Typically, a page is 4 KB in size.
Your two view accessors represent parts of the file that are within the same 4 KB region. Therefore, the virtual memory pages you are using here essentially map to the very same 4 KB region in the file. (Note how the block1
and block2
pointer values differ in exactly one 4 KB page size.
If you want to use separate view accessors, what you need to do is to calculate the start offset of the view. MemoryMappedViewAccessor.PointerOffset
might be helpful in that, but note that MemoryMappedViewAccessor.PointerOffset
is the offset from the start of the mapped file, not the offset from the (first) page of the view.
Or work just with a single view accessor and pointer arithmetic, as Sergei's answer demonstrates. This would be much simpler...