The VirtualLock function locks the specified region of the processs virtual address space into memory, ensuring that subsequent access to the region will not incur a page fault.
BOOL VirtualLock(
LPVOID lpAddress, | // address of first byte of range to lock |
DWORD dwSize | // number of bytes in range to lock |
); |
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
All pages in the specified region must be committed. Memory protected with the PAGE_NOACCESS flag cannot be locked.
Locking pages into memory may degrade the performance of the system by reducing the available RAM and forcing the system to swap out other critical pages to the paging file. By default, a process can lock a maximum of 25 or 30 pages. The default limit is intentionally small to avoid severe performance degradation. Applications that need to lock larger numbers of pages must first call the SetProcessWorkingSetSize function to increase their minimum and maximum working set sizes. The maximum number of pages that a process can lock is equal to the number of pages in its minimum working set minus a small overhead.
Bear in mind that locking a page of memory in Win32 does not mean that the page will not be paged to disk. On the contrary, it means that, while the process is running, the locked page of memory will be present in physical memory. It is not only possible, but likely, that the entire working set of pages for a process will be paged to disk when the process is idle. When the process wakes up, its working set of pages is immediately paged back into memory, including the VirtualLocked pages.
To unlock a region of locked pages, use the VirtualUnlock function. Locked pages are automatically unlocked when the process terminates.
This function is not like the GlobalLock or LocalLock function in that it does not increment a lock count and translate a handle into a pointer. There is no lock count for virtual pages, so multiple calls to the VirtualUnlock function are never required to unlock a region of pages.
GlobalLock, LocalLock, SetProcessWorkingSetSize, VirtualUnlock
file: /Techref/os/win/api/win32/func/src/f90_12.htm, 3KB, , updated: 2000/4/24 13:46, local time: 2024/12/27 09:34,
3.135.249.119:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/techref/os/win/api/win32/func/src/f90_12.htm"> VirtualLock</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.