|Portability||non-portable -- posix only|
|Maintainer||Don Stewart <email@example.com>|
mmap a file or device into memory as a strict ByteString. The file is not actually copied strictly into memory, but instead pages from the file will be loaded into the address space on demand.
For example, you can happily mmap a 1G file, as long as you only index small parts of it.
We can consider mmap as lazy IO pushed into the virtual memory subsystem.
For more details about mmap, and its consequences, see:
mmapFile function maps a file or device into memory.
If the mmap fails for some reason, an attempt is made
to copy the file into memory instead.
The storage manager is used to free the mapped memory. When the garbage collector notices there are no further references to the mapped memory, a call to munmap is made. It is not necessary to do this yourself. However, in tight memory situations, or if you have precise deallocation points, it is possible to call the unmap the allocated pointer directly.
Memory mapped files will behave as if they were read lazily -- pages from the file will be loaded into memory on demand.