mmap() question

RW rwmaillists at googlemail.com
Wed Oct 9 13:45:42 UTC 2013


On Wed, 9 Oct 2013 15:42:27 +0400
Dmitry Sivachenko wrote:

> Hello!
> 
> I have a program which mmap()s a lot of large files (total size more
> that RAM and I have no swap), but it needs only small parts of that
> files at a time.
> 
> My understanding is that when using mmap when I access some memory
> region OS reads the relevant portion of that file from disk and
> caches the result in memory.  If there is no free memory, OS will
> purge previously read part of mmap'ed file to free memory for the new
> chunk.
> 
>...
>
> It seems I incorrectly understand how mmap() works, can you please
> clarify what's going wrong?
> 
> I expect that program to run indefinitely, purging some regions out
> of RAM and reading the relevant parts of files.

I think your problem is that you are accessing the memory so rapidly
that the pages can't even get out of the active queue. The VM system
isn't optimized for this kind of abnormal access. 


More information about the freebsd-hackers mailing list