Subject: Re: Memory utilization for mmap files
To: Stuart Brooks <email@example.com>
From: Manuel Bouyer <firstname.lastname@example.org>
Date: 06/07/2004 16:21:32
On Mon, Jun 07, 2004 at 02:24:10PM +0200, Stuart Brooks wrote:
> Probably a bit of a silly question but if I mmap a file of 100kB in 5
> different processes (using MAP_FILE|MAP_SHARED), would my memory footprint
> (in terms of "real" memory usage) be
> a. 5*100kB = 500kB?
> b. a once off allocation of 100kB which is paged for the various processes?
> c. a variable amount per process depending on how it's accessed in the
> The man page for mmap is not terribly clear on this and I can't find another
> resources which answers this question so any help would be appreciated.
A mix of b and c. As it's MAP_SHARED, the same pages will be used by the 5
processes. However, as it's demand-paged, the pages won't be allocated and
filled by the file data until one of the 5 processes needs it.
But once a chunck of the file has been paged in by a process, it's avaiable
for the 5, until it's paged out due to memory shortage.
Manuel Bouyer <email@example.com>
NetBSD: 26 ans d'experience feront toujours la difference