Skip to content

Instantly share code, notes, and snippets.

@Sorseg
Created June 15, 2015 12:03
Show Gist options
  • Save Sorseg/400fe412268b0b798c28 to your computer and use it in GitHub Desktop.
Save Sorseg/400fe412268b0b798c28 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import wmi, time
def watch():
c=wmi.WMI()
pss = c.query("select WorkingSetSize from win32_Process"
" where Name='chrome.exe'")
killed = [p.Terminate(0) for p in pss if int(p.WorkingSetSize) > 1800*1e6]
if killed:
print ("SOMEONE GOT KILLED")
mem = sum(int(p.WorkingSetSize) for p in pss)
return mem
if __name__ == '__main__':
while 1:
print(watch()/1e6)
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment