Is there any reasons to not use "mmap" to read files?

rempas rempas at tutanota.com
Sun Feb 6 13:03:55 UTC 2022


On Sunday, 6 February 2022 at 12:52:45 UTC, Patrick Schluter 
wrote:
> mmap has quite the overhead to set up the page table for a 
> file. This means for small files, open/read/write calls (and 
> stdio which build on it) are faster.
>
> The other issue with mmap is if you use string functions on the 
> mapped part, you have to make sure that there are 0 bytes in 
> the file or else you risk these functions to overshoot to 
> unmapped pages and crashing the application.

Thank you! After all I've heard, I will probably stick with 
"read". The files I'm going to read are going to be some 
kilobytes (megabytes at worse) so I should probably be fine.


More information about the Digitalmars-d mailing list