less than 1 minute read

  以下来自百度百科和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:

  • memory allocation performed by the operating system for a program
  • 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;  
}  

  页面文件大小 ÷ 页面大小 = 页面数。

Categories:

Updated:

Comments