Created
June 26, 2018 13:54
-
-
Save chenfengyuan/74fa039f31618c9f496775de2339c732 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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