windowscommand-prompt

Get process memory on Windows


I have a library in Ruby that shells out to get memory usage of the current process, I just received a report that it doesn't work on Windows. On mac and linux I can shell out to ps -o rss= -p 3432 to get the RSS memory for process with a PID of 3432. Is there an equivalent command in Windows?


Solution

  • Not sure how linux measures RSS but in Windows for the working set size (the set of pages in the virtual address space of the process that are currently resident in physical memory) you can use WMIC to query WMI:

    C:\>wmic process where processid=6884 get WorkingSetSize
    WorkingSetSize
    253448192
    

    (Remove get WorkingSetSize for a list of the available metrics)