简体   繁体   中英

Disabling pagefile just for an application?

I have a real-time application running on a server with terrible disk IO access times (the actual transfer speed is great, but requesting disk-access can take seconds before being granted).

Windows moves memory into the page-file even when there's lots of physical memory available, and so ordinary applications can require disk-access even if they never explicitly try to access the disk.

Is there a way I can disable the page-file for an application pragmatically, rather than disabling the page file system wide?

您可以使用VirtualLock将进程的虚拟地址空间的指定区域锁定到物理内存中,从而确保对该区域的后续访问不会导致页面错误。

We experienced similar behaviour recently, with a process being paged out to the swap file, even though there was stacks of RAM still available.

The problem turned out to be the process priority. Firstly in Task Manager it was showing as Below Normal:

低于正常优先级

However it was more useful to check the Memory Priority from Process Explorer (from SysInternals). This shows on the Performance tab of the process properties:

内存优先

(A higher number is higher priority here).

When this was below 5, Windows would naturally start to page the process out if it was quiet for about 2 minutes. This was confirmed by watching the Page File usage percentage in Performance Monitor - the green line here: 页面文件使用


In our case, the cause was the default priority given to a task by the Task Scheduler in Windows. This defaults to Below Normal, and is also not visible in the UI. Instead you must export the task definition to XML, edit and re-import - as described here .

As that mentions, the default priority given to a task is 7. When that was changed to 4 in the XML, and re-imported:

<Priority>4</Priority>

... this was enough to stop the paging. In Task Manager the priority showed as Normal, in Process Explorer the Memory Priority went from 2 to 5.

(Look out, these numbers go in opposite directions).

It's worth noting, a <Priority> of 5 or 6 also showed as Normal in Task Manager, but the Memory Priority was still too low to prevent Windows pre-emptively paging.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM