Skip to content

Instantly share code, notes, and snippets.

@colesbury
Created July 28, 2020 02:02
Show Gist options
  • Save colesbury/eb066317ecaf571c9d126c34e8dbde8a to your computer and use it in GitHub Desktop.
Save colesbury/eb066317ecaf571c9d126c34e8dbde8a to your computer and use it in GitHub Desktop.
import gc
from time import sleep
import numpy as np
print('allocating memory')
pile=[]
for i in range(1500):
for x in range(4):
pile.append(np.ones((256, 64), dtype=np.float32))
pile.append(np.ones((256, 64), dtype=np.float32))
pile.append(np.ones((256,), dtype=np.float32))
pile.append(np.ones((256,), dtype=np.float32))
print('waiting two seconds')
sleep(2)
del pile
print('hypothetically de-allocating memory')
gc.collect()
print('waiting forever')
sleep(1)
while True:
sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment