Search code examples
performanceperformancecounterxperf

How much memory of a process is paged out?


Is there a Performance Counter which indicates how much of memory of a specific process is paged out? I have a server which has 40 GB of available RAM (of 128 GB physical memory) but the paged out amount of data is over 100 GB. How can I find out which of my processes are responsible for that huge page file consumption?

It would be also ok to have some xperf tracing to see when the page out activity happens. But apart from many writes to the page file I cannot see from which processes the memory is written to the page file.

Reference Set Tracing shows me only as far as I understand it how big the physical memory consumption of my process is. But it does not seem to track page out activity.

Update The OS is Windows Server 2012 R2


Solution

  • The ETW provider "Microsoft-Windows-Kernel-Memory" has a keyword "KERNEL_MEM_KEYWORD_WS_SWAP" ("0x80"). Here there are some events that occur when data are paged out/paged in:

         <event value="4" symbol="WorkingSetOutSwapStart" version="0" task="WorkingSetOutSwap" opcode="win:Start" level="win:Informational" keywords="KERNEL_MEM_KEYWORD_WS_SWAP" template="WorkingSetOutSwapStartArgs"/>
         <event value="4" symbol="WorkingSetOutSwapStart_V1" version="1" task="WorkingSetOutSwap" opcode="win:Start" level="win:Informational" keywords="KERNEL_MEM_KEYWORD_WS_SWAP" template="WorkingSetOutSwapStartArgs_V1"/>
         <event value="5" symbol="WorkingSetOutSwapStop" version="0" task="WorkingSetOutSwap" opcode="win:Stop" level="win:Informational" keywords="KERNEL_MEM_KEYWORD_WS_SWAP" template="WorkingSetOutSwapStopArgs"/>
         <event value="5" symbol="WorkingSetOutSwapStop_V1" version="1" task="WorkingSetOutSwap" opcode="win:Stop" level="win:Informational" keywords="KERNEL_MEM_KEYWORD_WS_SWAP" template="WorkingSetOutSwapStopArgs_V1"/>
         <event value="6" symbol="WorkingSetInSwapStart" version="0" task="WorkingSetInSwap" opcode="win:Start" level="win:Informational" keywords="KERNEL_MEM_KEYWORD_WS_SWAP" template="WorkingSetOutSwapStartArgs"/>
         <event value="6" symbol="WorkingSetInSwapStart_V1" version="1" task="WorkingSetInSwap" opcode="win:Start" level="win:Informational" keywords="KERNEL_MEM_KEYWORD_WS_SWAP" template="WorkingSetOutSwapStartArgs_V1"/>
         <event value="7" symbol="WorkingSetInSwapStop" version="0" task="WorkingSetInSwap" opcode="win:Stop" level="win:Informational" keywords="KERNEL_MEM_KEYWORD_WS_SWAP" template="WorkingSetInSwapStopArgs"/>
    

    Here you get some data like the number of pages accessed (PagesProcessed):

    <template tid="WorkingSetOutSwapStartArgs">
      <data name="ProcessId" inType="win:UInt32"/>
     </template>
     <template tid="WorkingSetOutSwapStopArgs">
      <data name="ProcessId" inType="win:UInt32"/>
      <data name="Status" inType="win:HexInt32"/>
      <data name="PagesProcessed" inType="win:UInt32"/>
     </template>
     <template tid="WorkingSetInSwapStopArgs">
      <data name="ProcessId" inType="win:UInt32"/>
      <data name="Status" inType="win:HexInt32"/>
     </template>
     <template tid="WorkingSetOutSwapStartArgs_V1">
      <data name="ProcessId" inType="win:UInt32"/>
      <data name="Flags" inType="win:HexInt32"/>
     </template>
     <template tid="WorkingSetOutSwapStopArgs_V1">
      <data name="ProcessId" inType="win:UInt32"/>
      <data name="Status" inType="win:HexInt32"/>
      <data name="PagesProcessed" inType="win:Pointer"/>
      <data name="WriteCombinePagesProcessed" inType="win:Pointer"/>
      <data name="UncachedPagesProcessed" inType="win:Pointer"/>
      <data name="CleanPagesProcessed" inType="win:Pointer"/>
     </template>
    

    Play with it if it includes all data you need.