A service processes very large log files and switches from `Files.lines()` to `FileChannel.map()` for a performance win. What is `MappedByteBuffer` actually doing differently from a normal read, and what's the operational catch nobody mentioned in the pull request?
A normal read (Files.lines, a BufferedReader) pulls bytes from the file into a buffer in your process's own memory through explicit read() system calls, one chunk at a time. FileChannel.map() does something structurally different: it maps a region of the file directly into the process's virtual address space, using the operating system's own memory-mapping mechanism, and returns a MappedByteBuffer that reads and writes straight against that mapping — no explicit per-call read/write syscall, pages of the file fault in lazily as your code actually touches them, going through the OS's page cache directly. That's genuinely faster for very large files or copying between two mapped regions, because it skips a copy through an intermediate user-space buffer. The operational catch: there is no public unmap() method. A mapped file has historically stayed "in use" from the OS's point of view until the MappedByteBuffer itself becomes unreachable and gets garbage collected — which means deleting or renaming a file you just finished mapping can behave unexpectedly if the mapping hasn't actually been released yet, and that's platform-dependent enough to be worth checking directly rather than assuming.