MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / get_system_memory

Function get_system_memory

emrun.py:1112–1133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1110
1111
1112def get_system_memory():
1113 try:
1114 if LINUX or emrun_options.android:
1115 if emrun_options.android:
1116 lines = check_output([ADB, 'shell', 'cat', '/proc/meminfo']).split('\n')
1117 else:
1118 mem = open('/proc/meminfo', encoding='utf-8')
1119 lines = mem.readlines()
1120 mem.close()
1121 for i in lines:
1122 sline = i.split()
1123 if str(sline[0]) == 'MemTotal:':
1124 return int(sline[1]) * 1024
1125 elif WINDOWS:
1126 import win32api
1127 return win32api.GlobalMemoryStatusEx()['TotalPhys']
1128 elif MACOS:
1129 return int(check_output(['sysctl', '-n', 'hw.memsize']).strip())
1130 elif FREEBSD:
1131 return int(check_output(['sysctl', '-n', 'hw.physmem']).strip())
1132 except Exception:
1133 return -1
1134
1135
1136# Finds the given executable 'program' in PATH. Operates like the Unix tool 'which'.

Callers 1

get_system_infoFunction · 0.85

Calls 4

check_outputFunction · 0.85
splitMethod · 0.80
openFunction · 0.50
closeMethod · 0.45

Tested by

no test coverage detected