Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to lock pages in memory using WinAPI?

I need to prevent application's memory pages from being swapped out of RAM on Windows. Is there a WinAPI function equivalent of POSIX mlockall() to achieve that?

like image 544
Alex B Avatar asked Dec 17 '09 00:12

Alex B


People also ask

How do you check if lock pages in memory is enabled in SQL Server?

whoami.exe has the ability to report all the rights held by the account executing whoami . This, combined with the xp_cmdshell provides a reliable way to determine if the instance of SQL Server has the necessary right to lock pages in memory. If xp_cmdshell is not enabled, this code returns UNKNOWN .


1 Answers

Yes, VirtualLock(). There's a limit on how many pages you can lock, you can't hog RAM. Details are in the MSDN article.

like image 110
Hans Passant Avatar answered Sep 28 '22 18:09

Hans Passant