Java NIO 2.0 : Memory-Mapped Files | MappedByteBuffer Tutorial - HowToDoInJava
Advantages of Memory-Mapped Files
Memory-Mapped IO have several advantages over normal I/O:
- The user process sees the file data as memory, so there is no need to issue
read()orwrite()system calls. - As the user process touches the mapped memory space, page faults will be generated automatically to bring in the file data from disk. If the user modifies the mapped memory space, the affected page is automatically marked as dirty and will be subsequently flushed to disk to update the file.
- The virtual memory subsystem of the operating system will perform intelligent caching of the pages, automatically managing memory according to system load.
- The data is always page-aligned, and no buffer copying is ever needed.
- Very large files can be mapped without consuming large amounts of memory to copy the data.
Read full article from Java NIO 2.0 : Memory-Mapped Files | MappedByteBuffer Tutorial - HowToDoInJava
No comments:
Post a Comment