Good day to all, tell me how to get information about the process memory from psutil so that it corresponds to the task manager? For example, I use this thing:

import psutil for proc in psutil.pids(): try: p = psutil.Process(proc) m = p.memory_info_ex() print (p.name(), m) except: pass 

Which as a result deduced a name of process and all its information, but I there did not find representation necessary. Maybe you need some more arithmetic?

There, all the numbers in bytes are issued, according to the documentation, from the dispatcher into bytes translated and compared. I tried to reduce everything to kilobytes - it also did not converge.

  • But how much does it differ, and what numbers do you compare? psutil.memory_info returns 7 parameters - vms, rss, shared, text, lib, data, dirty. you need rss as I understand it - rusnasonov
  • I need an rss idea, yes, but diverge like this: in the task manager 2404KB, and in the rss parameter - 6950912L - Alexander

1 answer 1

In Windows, there is a resource monitor (called from the task manager), so the rss parameter displays information from the “Working set” column, and the task manager itself does not display the full memory, but only the private one.

  • What is a "working set" clearly (recently used process pages) is close to the concept of RSS (process pages that are in physical memory right now) And what do you mean by "real memory", "full memory", "private memory"? For example, if a process uses a dll, then does the memory consumed by it go into "real memory". If the second process starts, which uses the same already loaded dll, do you want to read the memory twice under the dll or only once in the "real memory"? How will these values ​​change, if before loading the second process, dll lay in the swap? - jfs
  • By real memory, I mean the memory that is displayed in the task manager, under the full memory - along with the cache and libraries, and under private memory - only the process itself without libraries and other things) - Alexander
  • that is, "real memory" == "working set" in your terms? What do you mean by "cache" (file caches? - then where is the memory of the process?). The "working set" may include libraries loaded into memory (for example, if recently used). Task Manager can show multiple columns. The "memory" column in the task manager shows the "private working set" (which is obviously different from just the "working set" column in the task manager). Here is the question of which memory metrics are shown in Windows and what they mean - jfs