Memory usage information
Details
ps_memory_info()
returns information about memory usage.
It returns a named vector. Portable fields:
rss
: "Resident Set Size", this is the non-swapped physical memory a process has used (bytes). On UNIX it matches "top"‘s 'RES' column (see doc). On Windows this is an alias forwset
field and it matches "Memory" column oftaskmgr.exe
.vmem
: "Virtual Memory Size", this is the total amount of virtual memory used by the process (bytes). On UNIX it matches "top"‘s 'VIRT' column (see doc). On Windows this is an alias for thepagefile
field and it matches the "Working set (memory)" column oftaskmgr.exe
.
Non-portable fields:
shared
: (Linux) memory that could be potentially shared with other processes (bytes). This matches "top"‘s 'SHR' column (see doc).text
: (Linux): aka 'TRS' (text resident set) the amount of memory devoted to executable code (bytes). This matches "top"‘s 'CODE' column (see doc).data
: (Linux): aka 'DRS' (data resident set) the amount of physical memory devoted to other than executable code (bytes). It matches "top"‘s 'DATA' column (see doc).lib
: (Linux): the memory used by shared libraries (bytes).dirty
: (Linux): the amount of memory in dirty pages (bytes).pfaults
: (macOS): number of page faults.pageins
: (macOS): number of actual pageins.
For the explanation of Windows fields see the PROCESS_MEMORY_COUNTERS_EX structure.
ps_memory_full_info()
returns all fields as ps_memory_info()
, plus
additional information, but typically takes slightly longer to run, and
might not have access to some processes that ps_memory_info()
can
query:
uss
: Unique Set Size, this is the memory which is unique to a process and which would be freed if the process was terminated right now.pss
(Linux only): Proportional Set Size, is the amount of memory shared with other processes, accounted in a way that the amount is divided evenly between the processes that share it. I.e. if a process has 10 MBs all to itself and 10 MBs shared with another process its PSS will be 15 MBs.swap
(Linux only): amount of memory that has been swapped out to disk.
They both throw a zombie_process()
error for zombie processes.
See also
Other process handle functions:
ps_children()
,
ps_cmdline()
,
ps_connections()
,
ps_cpu_times()
,
ps_create_time()
,
ps_cwd()
,
ps_descent()
,
ps_environ()
,
ps_exe()
,
ps_handle()
,
ps_interrupt()
,
ps_is_running()
,
ps_kill()
,
ps_name()
,
ps_num_fds()
,
ps_num_threads()
,
ps_open_files()
,
ps_pid()
,
ps_ppid()
,
ps_resume()
,
ps_send_signal()
,
ps_shared_libs()
,
ps_status()
,
ps_suspend()
,
ps_terminal()
,
ps_terminate()
,
ps_uids()
,
ps_username()
Examples
p <- ps_handle()
p
#> <ps::ps_handle> PID=6015, NAME=R, AT=2024-10-29 08:51:51.83
ps_memory_info(p)
#> rss vms shared text lib data dirty
#> 257851392 943390720 30146560 4096 0 752361472 0
ps_memory_full_info(p)
#> rss vms shared text lib data dirty
#> 257851392 943390720 30146560 4096 0 752361472 0
#> uss pss swap
#> 240656384 243924992 0