16 ms·
I think you don’t need to be unsafe, they have normal API for it. https://learn.microsoft.com/en-us/dotnet/standard/io/memory-mapped-files https://learn.micros
by SvenL 7mo ago
I think you don’t need to be unsafe, they have normal API for it.
https://learn.microsoft.com/en-us/dotnet/standard/io/memory-mapped-files https://learn.microsoft.com/en-us/dotnet/standard/io/memory-...
- Const-me 7mo agoIndeed, but these normal APIs have runtime costs for bounds checking. For some use cases, unsafe can be better. For instance, last time I used a memory-mapped file was for a large immutable Bloom filter. I knew the file should be exactly 4GB, validated that in the constructor, then when testing 12 bits from random location of the mapped file on each query, I opted for unsafe codes.
- pjmlp 7mo agoIt is a matter of the deployment scenario, in the days people ship Electron, and deploy production code in CPython, those bounds checking don't hurt at all. When they do, thankfully there is unsafe if needed.