Skip to content

Instantly share code, notes, and snippets.

@Fak3
Created December 31, 2018 17:53
Show Gist options
  • Save Fak3/3c6bf52000651b00d9ab03e5b6bae677 to your computer and use it in GitHub Desktop.
Save Fak3/3c6bf52000651b00d9ab03e5b6bae677 to your computer and use it in GitHub Desktop.
ramhog.py
from time import sleep
print('Press ctrl-c to exit; Press enter to hog 100MB more')
one = b'Z' * 1024 * 1024 # 1MB
hog = []
while True:
hog.append(one * 100) # allocate 100MB
free = '; '.join(open('/proc/meminfo').read().split('\n')[1:3])
print(f'{free}; Press enter to hog 100MB more', end='')
input()
sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment