Reputation: 4516
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?
Upvotes: 6
Views: 1761
Reputation: 10931
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.
Upvotes: 2
Reputation: 19403
You can use VirtualLock to lock a specified region of the process's virtual address space into physical memory, ensuring that subsequent access to the region will not incur a page fault.
Upvotes: 5