Subject: Re: mmap eats memory
To: Andrew Kilpatrick <firstname.lastname@example.org>
From: Chuck Silvers <email@example.com>
Date: 02/19/2001 23:45:42
er, let me amend that to be "no way ... without changing the application."
if you can change the application, then you could use madvise()
to set MADV_SEQUENTIAL on the mapping before you scan through it
(if you're always accessing sequentially). if you're also accessing
the mapping randomly, then this won't necessarily save you.
you can also experiment with MADV_FREE to explicitly flush ranges of
the file data if need be, but that would be more complicated.
On Mon, Feb 19, 2001 at 11:30:03PM -0800, Chuck Silvers wrote:
> funny you should mention this just now...
> I'm going to check in some changes to -current in the next few days
> which will provide a way to control mmap's memory usage.
> right now there is no way to prevent the problem you're seeing.
> On Tue, Feb 20, 2001 at 01:24:59AM -0500, Andrew Kilpatrick wrote:
> > Hi,
> > I'm using mmap to provide access to very large audio
> > files. (possibly 300-600 megs) When I scan through an
> > entire file, the resident size of my process grows
> > and grows until the RAM on the machine is full and all
> > other processes are swapped to disk.
> > Is this normal? And is there any way of preventing
> > huge memory usage while still giving simple memory-mapped
> > access to very large files?
> > Any comments would be appreciated.
> > Andrew Kilpatrick