如何使用 WinAPI 锁定内存中的页面?

发布于 2024-08-15 07:12:12 字数 189 浏览 1 评论 0原文

我需要防止应用程序的内存页面在 Windows 上从 RAM 中换出。是否有与 POSIX 等效的 WinAPI 函数 mlockall() 达到这个目的?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

七婞 2024-08-22 07:12:12

是的,VirtualLock()。您可以锁定的页面数量是有限制的,您不能占用内存。详细信息请参阅 MSDN 文章

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

乖不如嘢 2024-08-22 07:12:12

我不得不问,为什么需要这样做?如果每个应用程序都认为其页面非常重要以至于不应该被调出,那么这将是对内存的巨大浪费。

如果页面正在使用中,它们不会被发送到页面文件,如果它们没有在使用中,为什么还要保留它们呢?相信嗯,它是由一个非常聪明的人编写的 :)

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 :)

客…行舟 2024-08-22 07:12:12

您好,您可以设置内存中锁定页面的 Windows 选项。通常此设置主要由 SQL Server 使用,但也适用于其他应用程序。请在 msdn 上查看此网站,

为您的设备启用寻址 Windows 扩展 (AWE)应用。请参阅 msdn 上的此链接

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文