VirtualLock() Only Locks Pages into Working Set

ID: Q94996

3.10 3.50 3.51 4.00 WINDOWS NT kbprg

The information in this article applies to:

SUMMARY

VirtualLock() causes pages to be locked into an application's working set (virtual memory); it does not lock them absolutely into physical memory. VirtualLock() essentially means "this page is always part of the process's working set."

The system is free to swap out any virtually locked pages if it swaps out the whole process. And when the system swaps the process back in, the virtually locked pages (similar to any virtual pages) may end up residing in different real pages.

It is wise to use VirtualLock() very sparingly because it reduces the flexibility of the system.

Depending upon memory demands on the system, the memory manager may vary the number of pages a process can lock. Under typical conditions you can expect to be able to VirtualLock() approximately 28 to 32 pages.

In Windows NT 3.5, you can use SetProcessWorkingSetSize() to increase the size of the working set, and therefore increase the number of pages that VirtualLock() can lock.

KBCategory: kbprg KBSubcategory: BseMm Additional reference words: 3.10 3.50 3.51 4.00

Keywords          : kbAPI kbKernBase kbGrpKernBase 
Version           : 3.10 3.50 3.51 4.00
Platform          : NT WINDOWS

Last Reviewed: December 22, 1996