3 ms·
I do not understand why this would possibly be a concern. You do realize that there is no cost to memory mapping a very large file, right? You still are going
by saurik 14y ago
I do not understand why this would possibly be a concern.
You do realize that there is no cost to memory mapping a very large file, right? You still are going to end up with only a single VMA ("virtual memory area", one of the more insidious costs of memory maps) in your memory map, and only pages you use will get paged in; if you wanted to memory map a 1GB large file, the only pain would be the loss of address space, and you have 2-3GB of that available.
Additionally, you aren't even correct that you have to memory map the entire file: as you have a file descriptor for the file and know the offset you want into the file, you can memory map just the part of the file you need. Both the C-level mmap API and the Java-level FileChannel.map API allow you to provide a specific offset and length for the region you want to map from the file.