[ANN] Memory mapped files for POSIX and Windows

David Roundy droundy at darcs.net
Tue Mar 18 15:15:48 EDT 2008

On Tue, Mar 18, 2008 at 01:46:28PM +0000, Gracjan Polak wrote:
> I just uploaded mmap to hackage:
> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mmap
> The package provides memory mapping abstractions for both POSIX and Windows
> systems like Vista, Linux and Mac OSX. This library provides a wrapper to
> mmap(2) or MapViewOfFile, allowing files or devices to be lazily loaded into
> memory as strict or lazy ByteStrings, ForeignPtrs or even plain Ptrs, using
> the virtual memory subsystem to do on-demand loading. Modifications are also
> supported.
> Package includes a cp-like copy utility that uses different mechanisms to copy
> contents of file. Here come some statistics from using it on 90MB file:

Incidentally, you'll probably find that for large files, using mmap on
Windows is a huge loser when compared with lazy bytestrings.  As far as I
understand, on Windows when a file is mmapped, its entire contents are
immediately loaded into memory, so if you mmap a file that is larger than
your memory, you pay a huge penalty on Windows.

I'm not sure what the target audience for this library is, but I'd be
surprised if it turns out to be useful for much more than toy projects (or
posix-only projects), just because the Windows file system semantics are so
screwed up.  :(
David Roundy
Department of Physics
Oregon State University

More information about the Libraries mailing list