Created
March 5, 2018 19:53
-
-
Save hiroto-takatoshi/1efc7dddab110bd280a5fe9acb96fcad to your computer and use it in GitHub Desktop.
get game memory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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