Why Windows Cache Can Exceed Its Virtual Size

本文探讨了Windows操作系统中缓存管理器如何使用内存映射文件进行缓存,并解释了为什么缓存虚拟大小可以超过实际内存限制。通过分析缓存的工作集、备用列表以及文件映射视图的工作原理,揭示了提高缓存效率的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Why Windows Cache Can Exceed Virtual

Fan Decheng
2007-06-26

These days I have been not understanding why Windows cache is not limited to the maximum cache virtual size 960MB. This is said in the "Cache Physical Size" section in the Windows Internals, 4th Edition book.

The reason is, Cache Manager uses sections objects (or called memory mapped files) to do caching. A section object maps a view of a file or a view of a certain amount of memory (RAM plus the paging file) into a virtual address range. Thus, the section object can be shared among applications.

There are two stages of a section object view access. The first stage is to map the view. After mapping the view, the virtual address space corresponds to the view of the file or amount of memory. The second stage is to access the pages. When a page is accessed, it is read into the RAM by the memory manager (by calling the file system driver).

In the case of the Cache Manager, only views of files are related. As we know, there are VACB arrays. Each one of them correspond to a section object mapping a view of a 256KB block of a file. Now, it is said that the virtual size of the cache is 960MB. This means that the virtual address space occupied by the section objects add up to no more than 960MB.

For example, when a part of a file is being accessed, the file system driver asks the Cache Manager to get the part. The Cache Manager checks to see if the part of the file is mapped in one of the section objects. If it is, then the Cache Manager accesses the virtual memory pages to retrieve it. If it is not mapped, then the Cache Manager maps a view of it through Memory Manager. But at that time, it is still not read from the disk. However, immediately the Cache Manager accesses the pages. Then the Memory Manager reads the file from the disk by calling the file system driver.

Sometimes the pages are already in RAM. It may be in the cache working set or in the standby list. Even unmapped views of files may still stay in the standby list. The cache working set means pages that are accessed by the Cache Manager so that they are referenced by page tables for the system cache.

The reason why the Cache Manager has a virtual size possibly larger than the RAM is for efficiency. Mapping and unmapping views is slow, so it is best avoided when not necessary.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值