Skip to content

Instantly share code, notes, and snippets.

@hiroto-takatoshi
Created March 5, 2018 19:53
Show Gist options
  • Save hiroto-takatoshi/1efc7dddab110bd280a5fe9acb96fcad to your computer and use it in GitHub Desktop.
Save hiroto-takatoshi/1efc7dddab110bd280a5fe9acb96fcad to your computer and use it in GitHub Desktop.
get game memory
import psutil
def findgame():
for _ in psutil.pids():
try:
name = psutil.Process(_).name()
except psutil.NoSuchProcess:
continue
if name == "TslGame.exe":
return _
return None
def getgamemem():
gamepid = findgame()
if gamepid is not None:
gameproc = psutil.Process(gamepid)
gamepmem = gameproc.memory_info()
return gamepmem.rss / 1024.0 / 1024.0
else :
return None
print(getgamemem())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment