Last active
April 27, 2020 19:27
-
-
Save timcharper/d7f3808d6f4fdc448391cbc65a390adc to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python3 | |
from time import sleep | |
from sys import exit, argv, getsizeof | |
# this simple python script allocates memory, waits for a while, and then exits successfully | |
mem = 0 | |
try: | |
mem = int(argv[1]) | |
except ValueError: | |
print("Usage: mem.py <mb-to-allocate>") | |
exit() | |
bytes = mem * 1024 * 1024 | |
print("Allocating {} bytes".format(bytes), flush=True) | |
reference = bytearray(bytes) | |
while True: | |
sleep(1) | |
print("Allocated size: {}...".format(getsizeof(reference)), flush=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment