bytestring-mmap-0.1.1: mmap support for strict ByteStrings

Portabilitynon-portable -- posix only
MaintainerDon Stewart <>



mmap a file or device into memory as a strict ByteString.



mmapFile :: FilePath -> IO ByteStringSource

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

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

If the file size is less than 16*1024, it is more efficient to simply copy the file, so an mmap is not performed for small files. In the normal case, the file need never be copied.