2

I'm working on a program running on Linux that uses mmap to map a number of files to memory.

Each of the files is read (walking the memory with pointers).

You clearly see in pmap how some files were completely mapped to memory (when read entirely) and others were not:

Address           Kbytes     RSS   Dirty Mode  Mapping
00007f8b09c3a000   26688   26664       0 rw-s- /mnt/ebs-metadata/fullyread.dat
00007f89ecc0c000   15936    4704       0 rw-s- /mnt/ebs-metadata/partiallyread.dat

We continue mapping files and at a certain point in time we get an error saying more memory can't be allocated.

(Yes, we can unload many files, and we will do).

My question is: why the OS doesn't unload many of the pages (or even full files) from physical memory until the next use instead of throwing "cannot allocate memory"?

pablo
  • 6,392
  • 4
  • 42
  • 62

0 Answers0