开发者

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?


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


I have to ask, why do you need to do this? If every app thought its pages were so important that they shouldn't be paged out ever, it would be a giant waste of memory.

If the pages are in use, they won't be sent to the pagefile, and if they're not in use, why keep them around? Trust in Mm, it was written by a very smart guy :)


Hi you can set the windows option of lock pages in memory. Usually this setting is mostly used by SQL Server, but works also for other applications. Check this site on msdn

enable addressing windows extensions (AWE) for your application. See this link on msdn

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜