VirtualLock() Only Locks Pages into Working Set

Last reviewed: December 20, 1996
Article ID: Q94996
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.1, 3.5, 3.51, 4.00
    

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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 20, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.