MCPcopy Index your code
hub / github.com/numpy/numpy / _get_mem_available

Function _get_mem_available

numpy/testing/_private/utils.py:2753–2774  ·  view source on GitHub ↗

Return available memory in bytes, or None if unknown.

()

Source from the content-addressed store, hash-verified

2751
2752
2753def _get_mem_available():
2754 """Return available memory in bytes, or None if unknown."""
2755 try:
2756 import psutil
2757 return psutil.virtual_memory().available
2758 except (ImportError, AttributeError):
2759 pass
2760
2761 if sys.platform.startswith('linux'):
2762 info = {}
2763 with open('/proc/meminfo') as f:
2764 for line in f:
2765 p = line.split()
2766 info[p[0].strip(':').lower()] = int(p[1]) * 1024
2767
2768 if 'memavailable' in info:
2769 # Linux >= 3.14
2770 return info['memavailable']
2771 else:
2772 return info['memfree'] + info['cached']
2773
2774 return None
2775
2776
2777def _no_tracing(func):

Callers 1

check_free_memoryFunction · 0.85

Calls 5

openFunction · 0.85
startswithMethod · 0.80
splitMethod · 0.80
lowerMethod · 0.80
stripMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…