Skip to content

Instantly share code, notes, and snippets.

@chenfengyuan
Created June 26, 2018 13:54
Show Gist options
  • Save chenfengyuan/74fa039f31618c9f496775de2339c732 to your computer and use it in GitHub Desktop.
Save chenfengyuan/74fa039f31618c9f496775de2339c732 to your computer and use it in GitHub Desktop.
class A():
def __del__(self):
pass
def foo():
a=A()
b=A()
a.a=b
b.a=a
b.data = [0] * 1000 * 1000 * 100
import time, gc
del a, b
gc.collect()
print('done')
time.sleep(9999)
foo()
#python2 memory-leak.py
# after done is printed, RES is about 770M
#python3.6 memory-leak.py
# after done is printed, RES is about 8k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment