本科的课没学好,今天补上。
以下资料来自百度百科和Wikipedia。
内存在计算机中的作用很大,电脑中所有运行的程序都需要经过内存来执行,如果执行的程序很大或很多,就会导致内存消耗殆尽。
为了解决这个问题,Windows中运用了虚拟内存技术,即拿出一部分硬盘空间来充当内存使用,以缓解内存的紧张。不过虚拟内存只是暂时存储物理内存的内容,任何使用中的内存都只能从物理内存中读取。
充当虚拟内存的这部分硬盘空间即是页面文件,具体说来就是XP系统下的pagefile.sys这个文件。
页面文件的组成单位为页面。
In a context of computer virtual memory, a page, memory page, or virtual page is a fixed-length block of main memory (actually copy of main memory), that is contiguous in both physical memory addressing and virtual memory addressing. A page is usually a smallest unit of data for the following:
(1) memory allocation performed by the operating system for a program,
(2) transfer between main memory and any other auxiliary store, such as hard disk drive.
所以一个页面的大小应该和磁盘块大小一样,为4KB。
查看本机页面大小可以用下列程序:
#include <stdio.h> #include <windows.h> int main(void) { SYSTEM_INFO si; GetSystemInfo(&si); printf("The page size for this system is %u bytes.\n", si.dwPageSize); return 0; }
页面文件大小÷页面大小=页面数。