Win32 virtual memory and physical memory within the storage management

Source: Internet
Author: User

WIN32 Storage Management One, virtual memory and physical memory

We know that each application has its own independent 4GB space. Assuming that address 123 of a process stores 10, then the 123 address of the B process stores 20

Then the two of them do not affect each other. But the value is real. The value is stored in physical memory. As shown in.

According to the example. We can distinguish between virtual memory and physical memory. If we change the value of the physical memory. Then it will affect the a process or the B process.

Of course, if you've learned the kernel driver, you know that kernel-driven read-write is what you mean. I also wrote a simple kernel driver read and write. See the kernel driver directory for details.

So, virtual memory is fake. stored in physical memory when used

Second, the management of physical memory.

Physical memory is managed using a 4K approach. That is, 4,096 bytes. Also become a page. So when we use the API later. Most will find the page related. This is also because management is the reason for page management.

As shown

  

The value of process A is placed in the physical page.

And our process in the traditional sense is the 4GB actually divided into high and low 2G. Two grams of high are used for the kernel. So the user can only use low 2G. The lower two g also has high and low 64k can not be used. (Learn the kernel want to use their own structure can)

As shown in the following:

The memory that user mode can use is the orange position. But there is no corresponding physical page. When we apply for memory, we have the corresponding physical page.

If you want to see the three-ring program to use the physical page. Can be debugged by two machines. Debug our program. Use WinDbg.

1. Use the command first! The process iterates through the address of our program EXE.

2. Use the DT eprocess traversal address to get the eprocess structure of this application.

3. Get the offset of eprocess + 11c (i.e. member) Vadroot. Use! VAD address. (eprocess + address) to derive the memory physical page used by this exe.

It doesn't matter if you don't use it. Watch:

This diagram illustrates the end of our linear address 10 start-10. Because the physical page is 4K stored. So 10 is 1000. The back size is 1000 and the following position is 20, which is the 2000 linear address.

Three, physical page size.

The physical page size is based on the size of your physical memory. This means that your physical memory is large enough to be converted. We can view the total number of your physical pages through the task Manager.

For example:

  

Let's convert it. 1048048/4 conversion to 16 is the number of physical pages that can be made. For example, our example is 3ff7c a physical page.

We can also use WinDbg DD for a look. Only the DD variable is required.

If our physical page is over. Then the operating system also supports the use of hard disks as physical memory.

Specific settings

Advanced-> Performance Settings, advanced system settings, computer properties, high-level virtual memory change.

And this fast memory will be saved on Windows. The file name is Pagefile.sys, which is usually a C-drive hidden file. We can pass

Everything to search for a bit.

Three, the operating system can recognize memory

The amount of memory we have available is the size of the physical page we have calculated + the size of the virtual memory. But the operating system doesn't recognize that much.

That means we've added a lot of physical memory. That's a little bit useless.

64G memory is recognized under 32-bit systems. WinXP can only recognize 4G memory. Specific knowledge requires learning the page table (PTE PDE) page Catalog table in the Windows kernel to be clear. Don't say much. Just need to know.

Win32 virtual memory and physical memory within the storage management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.