79343366

Date: 2025-01-09 16:29:40
Score: 0.5
Natty:
Report link

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...

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: PointOfView