Skip to content

Instantly share code, notes, and snippets.

@thewickedaxe
Created July 7, 2017 17:25
Show Gist options
  • Select an option

  • Save thewickedaxe/4cb8a3634effe0212a12f2e30a71e6f1 to your computer and use it in GitHub Desktop.

Select an option

Save thewickedaxe/4cb8a3634effe0212a12f2e30a71e6f1 to your computer and use it in GitHub Desktop.
Script to eat memory on python
import argparse
import time
GB = 1024 * 1024 * 1024
def parse_cmd_args():
"""
Parses command line args
"""
parser = argparse.ArgumentParser(description='Memory Eating utility for python')
parser.add_argument('-m', '--memory', type=int, default=-1, help='The amount of memory in gigs to eat', required = True)
args = parser.parse_args()
return args
def eat_memory(mem_to_eat):
"""
Eats memeory
:param mem_to_eat: The amount of memory to eat in gigs
"""
global GB
eat = "a" * GB * mem_to_eat
while True:
time.sleep(1)
def main():
"""
Main sentinel
"""
mem_to_eat = parse_cmd_args().memory
eat_memory(mem_to_eat)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment