2

On platforms which does not have enough memory and which does not actively swap memory to files, mmap can be used to manually get "more memory than physically available".

My question is, if we have already allocated some memory, and now the memory is not going to be used for a moment, so we wish to map it to file. Is there a unix system call to map such already allocated memory to file, without changing the virtual address?

It would be nice to "hibernate" certain portion of memory to file, and then recover them to the initial state when we need it. Is there a way to do that?

Mr User
  • 205
  • 1
  • 5

1 Answers1

1

You can't turn an anonymous mapping into a file-backed mapping, but you can tell the kernel to swap out the memory, by using the madvise syscall with the advice MADV_PAGEOUT.