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) – The psutil.Process for which to get the current memory usage. If None, a new psutil.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 new psutil.Process when proc is None. If proc and pid are both None, the ID of the current process is used to create the new psutil.Process. If proc is not None, 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.