MCPcopy Index your code
hub / github.com/python/mypy / get_meminfo

Function get_meminfo

mypy/dmypy_server.py:1017–1043  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1015
1016
1017def get_meminfo() -> dict[str, Any]:
1018 res: dict[str, Any] = {}
1019 try:
1020 import psutil
1021 except ImportError:
1022 res["memory_psutil_missing"] = (
1023 "psutil not found, run pip install mypy[dmypy] "
1024 "to install the needed components for dmypy"
1025 )
1026 else:
1027 process = psutil.Process()
1028 meminfo = process.memory_info()
1029 res["memory_rss_mib"] = meminfo.rss / MiB
1030 res["memory_vms_mib"] = meminfo.vms / MiB
1031 if sys.platform == "win32":
1032 res["memory_maxrss_mib"] = meminfo.peak_wset / MiB
1033 else:
1034 # See https://stackoverflow.com/questions/938733/total-memory-used-by-python-process
1035 import resource # Since it doesn't exist on Windows.
1036
1037 rusage = resource.getrusage(resource.RUSAGE_SELF)
1038 if sys.platform == "darwin":
1039 factor = 1
1040 else:
1041 factor = 1024 # Linux
1042 res["memory_maxrss_mib"] = rusage.ru_maxrss * factor / MiB
1043 return res
1044
1045
1046def find_all_sources_in_build(

Callers 1

cmd_statusMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…