是否可以为单个进程禁用页面文件? [英] Is it possible to disable pagefile for a single process?

查看:96
本文介绍了是否可以为单个进程禁用页面文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个"cache managar"应用程序,当它消耗大量内存时,它能够将缓冲区保存到磁盘.出于这个事实,我认为使用页面文件非常愚蠢",因为我想要所有内容或将其存储在实存储器中,否则我自己将缓冲区保存到磁盘中.但是,不幸的是,我无法禁用页面文件,除非我对整个计算机都这样做.

因此,可以为单个应用程序禁用页面文件吗?就我而言,接收内存不足异常比将任何内容保存在此类应用程序的页面文件中要好.

I have a "cache managar" application which is capable of saving buffers to disk when they are consuming to much memory. By that fact, I think it is very "stupid" to use the page-file, as I want everything or to be in real-memory, or I myself will be saving buffers to disk. But, unfortunatelly, I am not able to disable the page file, except if I do that for the entire machine.

So, is it possible to disable the pagefile for a single application? In my case, it is better to receive an out-of-memory exception than to save anything in the page-file for such an application.

推荐答案

不,您无法禁用应用程序的分页系统.
您可能实际上使情况更糟:您确实意识到磁盘访问也被缓存了吗?
No, you can''t disable the paging system for an application.
You may actually make things worse: you do realize that disk accesses are cached as well?


OriginalGriff有一个好处,听起来您可以从使用MemoryMappedFile类 [
OriginalGriff has a good point, and it sounds like you possibly could benefit from using the MemoryMappedFile Class[^] to provide the required functionality. It''s just a thought :)

Regards
Espen Harlinn


不过,您可以使用VirtualLock将其锁定到物理内存中.我没有尝试锁定程序(代码部分),但是您可以尝试一下.请注意,您必须首先获得使用VirtualProtectEx写入该内存的权利,因为通常情况下它将具有PAGE_NOACCESS属性.您还需要注意,也许某些病毒扫描程序可能会将其作为自我修改代码,并将其报告为威胁.

http://msdn.microsoft.com/en-us/library/aa366895%28v = VS.85%29.aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/aa366899%28v = vs.85%29.aspx [ ^ ]

对于数据存储器,您可以简单地使用VirtualAllocEx和VirtualLock/VirtualUnlock.那应该工作得很好.

祝你好运!
You can however lock it into physical memory using VirtualLock. I have not tried to lock the program (code section) but you could give it a try. Be aware that you must first get the right to write to that memory using VirtualProtectEx because normally that would have the PAGE_NOACCESS attribute. You also need to be aware that maybe some virus scanners may pick this up as self-modifying-code and report this as a threat.

http://msdn.microsoft.com/en-us/library/aa366895%28v=VS.85%29.aspx[^]

http://msdn.microsoft.com/en-us/library/aa366899%28v=vs.85%29.aspx[^]

For data memory you can simply use VirtualAllocEx and VirtualLock/VirtualUnlock. That should work very nicely.

Good luck!


这篇关于是否可以为单个进程禁用页面文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆