Obviously, mmap
is limited by the size of the largest available block of virtual address space. But let's assume we have a 64-bit system, where this is almost unlimited for most purposes. Let's also assume no swap partition is configured.
In the case of an anonymous mapping, the size would have to be limited to the total amount of physical memory available.
However, in the case of a file-backed mapping, I wonder if there is a limit based on the amount of physical memory, e.g., the size of the mapping can be at most X times the amount of physical memory? Or will mmap
allow me to map arbitrarily large files as a single chunk as long as virtual address space limits are not hit? For example, if I have 32 GiB of RAM, can I successfully mmap
a 1 TiB disk file?
Asking about Linux specifically, in case it matters. (I tried with a 64 GiB file, and it seems to work. Unfortunately I don't have much more disk space available than that.)