MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / physical_free_linux

Function physical_free_linux

bleachbit/Memory.py:205–218  ·  view source on GitHub ↗

Return the physical free memory on Linux

()

Source from the content-addressed store, hash-verified

203
204
205def physical_free_linux():
206 """Return the physical free memory on Linux"""
207 free_bytes = 0
208 with open("/proc/meminfo") as f:
209 for line in f:
210 line = line.replace("\n", "")
211 ret = re.search(r'(MemFree|Cached):[ ]*([0-9]*) kB', line)
212 if ret is not None:
213 kb = int(ret.group(2))
214 free_bytes += kb * 1024
215 if free_bytes > 0:
216 return free_bytes
217 else:
218 raise Exception("unknown")
219
220
221def physical_free_windows():

Callers 1

physical_freeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected