mem_usage
- mdtools.run_time_info.mem_usage(proc=None, pid=None, unit='MiB')[source]
Get current memory usage.
Returns the current memory usage of a given process. If proc and pid are
None
, the current memory usage of the process that calls this function is returned.- Parameters:
proc (
psutil.Process
) – Thepsutil.Process
for which to get the current memory usage. IfNone
, a newpsutil.Process
instance is created for the given pid.pid (
int
) – The ID of the OS process for which to get the current memory usage. Is only used to create a newpsutil.Process
when proc isNone
. If proc and pid are bothNone
, the ID of the current process is used to create the newpsutil.Process
. If proc is notNone
, pid is meaningless.unit (
{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "KB", "MB", "GB", "TB", "PB"}
) – String determining the unit in which the memory usage should be returned. Default is mebibytes ("MiB"
).
- Returns:
mem (
float
) – Current memory usage of proc.