Relationship between physical memory, pagefile, and process address space-- Refreshing!
When a thread in a user process tries to access a data block in the address space of the process. Generally, two situations occur:
1. If the data the thread tries to access is in Ram, the CPU only needs to map the virtual address to the physical address of the memory, and then execute the required access.
2. The data is not in Ram, but somewhere in the page file. At this time, access will cause page failure. The CPU will notify the operating system, and the operating system will find a blank page from Ram. If no blank page is found, a page must be released. If the page has not been modified, it can be released directly. Otherwise, you must first copy the page from Ram to the page swap file, and then the system enters the page file to find the data to be accessed, and load the data to the idle Memory Page. Then, the operating system updates its virtual memory address used to specify the data, which has now been mapped to the table in the corresponding physical memory address in Ram.
Windows provides three methods for memory management.They are:
1. virtual memory, which is most suitable for managing large objects and arrays of structures.
2. Memory ing files (MMF) are most suitable for managing large data streams (usually from files) and sharing data among multiple processes running on a single computer.
Like virtual memory, MMF can be used to reserve an address space area and submit the physical memory to this area. The difference between them is that physical storage comes from a file already on the disk, rather than a system page file.
3. The memory heap is the most suitable for managing a large number of small objects.