Skip to content

Instantly share code, notes, and snippets.

@Fak3
Created Dec 31, 2018
Embed
What would you like to do?
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