How to detect programmatically if the system is paging

2023-03-06T09:05:49.47+00:00

We are using memory mapped files to an extent where we produce data faster than the memory manager is able to write modified pages to the paging file. Ultimately this results in a stalling system where the user is not able to work anymore. What we want to do is to throttle our processing and data generation while the system is paging data to disk.

The problem is, that there is no signal or event (to our knowledge) that we can detect to see if we need to throttle.

Is there any signal/event for paging?

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 44,751 Reputation points
    2023-03-07T15:36:59.3766667+00:00

    Hello there,

    You can use the GlobalMemoryStatusEx function to determine how much memory your application can allocate without severely impacting other applications.

    The information returned by the GlobalMemoryStatusEx function is volatile. There is no guarantee that two sequential calls to this function will return the same information.

    The ullAvailPhys member of the MEMORYSTATUSEX structure at lpBuffer includes memory for all NUMA nodes.

    https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-globalmemorystatusex

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–


  2. Gary Nebbett 6,216 Reputation points
    2023-03-07T17:10:41.0366667+00:00

    Hello Martin,

    The only way I can think of tracking paging I/O is to use a real-time ETW (Event Tracing for Windows) session to trace file I/O; the read and write events include "flags" information that will have the IRP_PAGING_IO bit set (and the IRP_NOCACHE bit set too) for paging reads/writes.

    Personally, I doubt that monitoring paging I/O specifically would be a good design decision. If your software can be throttled without any major drawbacks, then a more general test of the impact on system responsiveness would probably be easier to implement. One could also consider whether locking memory (e.g. via VirtualLock) could reduce the amount of paging caused by your application.

    If SHS means what I think, it might be worthwhile talking to Alois Kraus.

    Gary


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.