dotnet / dotnet/dotnet-api-docs
Docs for MemoryMappedViewAccessor/Stream.PointerOffset are incorrect
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
The docs for the property state "The number of bytes between the starting position of this view and the beginning of the memory-mapped file." That is incorrect. When a view stream or accessor is created, the implementation takes the user-supplied offset and tries to create a view at that position, but due to OS requirements, it may need to actually round down to the nearest acceptable boundary, such as a page boundary. Thus, the actual pointer stored inside the view stream or accessor may be for a smaller offset than the user actually provided. The public APIs on the stream or accessor account for this, internally storing the differential and including it in calculations to determine the actual position desired to be accessed. But if a developer gets the underlying pointer explicitly themselves, namely through AcquirePointer, they will need to manually include this offset, e.g. by doing `ptr + view.PointerOffset` to get the actual starting pointer for the view. So, PointerOffset doesn't return "the difference between the starting position for this view and the beginning of the memory-mapped file", but rather the difference between the requested starting position for this view and the actual starting position for this view.
cc: @jeffhandley @carlossanlop @jozkee
Contributor guide
Assessment
This issue has not been assessed yet.