标签:href back 通过 ram sof location 连续 html 运行
RAM是有限的,而虚拟内存则是无限的,因为可能有很多进程在运行,他们都需要各自的虚拟内存。这样可能就会出现RAM耗尽的情况。在此种情况下,系统则会把部分虚拟内存的pages存储到磁盘hard disk上去,每个page的大小为4KB。这些存储到磁盘的文件对应的就是系统上的Pagefiles.sys文件。注意,page对应的是虚拟地址的概念,而不是RAM的地址。
https://arstechnica.com/civis/viewtopic.php?t=925099
Virtual memory is a whole lot more than a page file.
Each byte of computer memory has an address.
In a system without virtual memory, the addresses that a program can see directly correspond to a physical memory location. This has a number of side-effects. One big one is that a program can see all the memory, even things that don‘t concern it -- it just has to look at the addresses that other programs are located. If a program inadvertantly writes to the wrong address, it might write on top of another program, damaging that program (that is, no memory protection). A program can‘t easily load a file that‘s bigger than the amount of memory installed in the computer. If your system has an ugly memory access scheme (for instance, segmented memory) you have to deal with that.
Virtual memory virtualizes memory addresses. It breaks the direct correlation between the memory addresses that programs can see, and the physical memory.
When done properly (MacOS since version 7 (IIRC) has virtualized addresses to make the memory space contiguous, where once it had holes, but doesn‘t really do anything beyond that -- this is "not properly") this gives you all sorts of benefits.
The way it‘s done (glossing over the details) is to have a look-up table, that maps virtual addresses to real addresses. It divides the set of addresses along 4 kbyte borders, and each 4 kbyte section -- called a page -- is treated as a single unit (so, for instance, if the OS wants to rearrange things how they lie in memory then it has to move whole pages around; if it wants to make a bit of memory read-only, it does it for a whole page at a time, etc.).
The first thing you do is to give each program its own set of virtual addresses. When you do this, you make it such that the addresses that one program can see have no relationship to the addresses another program can see. This means that each program is isolated from the other programs. You have protected memory. This introduces other problems (like, sharing data between programs), but they‘re solvable.
Because you have this indirection scheme (memory addresses get looked up), you can implement a disk paging scheme. Rather than a virtual address resolving to somewhere in-memory, it can resolve to somewhere on-disk -- you can have a system whereby you pull the information into memory from disk as and when needed. The opposite can also happen -- if a page isn‘t needed for a long time, and something else needs the memory, it can write the page out to disk -- the only drawback being, next time it needs to read it, it has to read it from the disk again.
With executables, it doesn‘t actually have to write anything out to disk -- it can get rid of its copy of the executable in memory, because it knows that it can read the original file again if it needs it back.
But with data, it can‘t do this, because the data has no on-disk representation. So what the OS does is to create a big file called the pagefile, which it can use to store data pages in this way.
Virtual memory doesn‘t require a pagefile -- it‘s a lot more than that (there are other things you can do that I haven‘t mentioned, that use the same system of pages and indirection), but a pagefile is a common part of an OS using virtual memory.
该回答的要点:
https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_chapter/libc_3.html
标签:href back 通过 ram sof location 连续 html 运行
原文地址:https://www.cnblogs.com/willhua/p/13168888.html