1. For small files, Windows generally provides enough methods to read files, and both performance and capacity can be used. The general practice is to read the entire file to the memory at a time and then read it in the memory. It mainly reduces the performance loss caused by I/O operations by reading the entire file at a time.
2. For large files, especially files with several GB or dozens of GB (CAD files are a typical type), the conventional method will not work. Obviously, the memory is read at a time, and the space is insufficient (<2 GB of process space is available; you cannot use it all). Windows provides MMF (memory ing file) to solve this problem. The usage of specific APIS is omitted here. The general idea of reading the huge file is as follows:
1) The image starting with the ing file.
2) access the image.
3) cancel this image
4) map a new image starting from a deeper shift in the file.
5) Repeat Step 2 until you access the full file data.
Memory ing file Overview
Memory file ing is also a memory management method for windows. It provides a unified memory management feature that enables applications Program The memory pointer can be used to access files on the disk. The process is like access to the memory where files are loaded. Using file ing, You can map all or part of the disk file to a region in the virtual address space of the process, and directly access the mapped file, you do not need to perform file I/O operations or buffer the file content. Memory file ing is very suitable for managing large-size files. Three purposes of using the memory ing file:
(1) The system uses a memory ing file to upload and execute the. exe and DLL files. This greatly saves the system page file space and shortens the time required to start the application.
(2) Use a memory ing file to access data on the disk. This not only avoids file I/O (input/output) operations on files, but also avoids applying a buffer for file content.
(3) Use a memory ing file to share data among multiple processes. Windows also provides other communication methods-but these methods are implemented using memory ing files.
3.
Both Native WIN32 and. Net 4.0 support using MMF directly. Boost library has its implementation.
Refer:
Http://blogguan.blog.sohu.com/77220236.html
Http://msdn.microsoft.com/en-us/library/ms810613.aspx
Http://msdn.microsoft.com/en-us/library/dd997372.aspx