Created
December 30, 2017 14:00
-
-
Save philippkeller/42bc9bd7c055788fff078fb91e009093 to your computer and use it in GitHub Desktop.
memory leak
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
| import time | |
| import tracemalloc | |
| import pympler.muppy, pympler.summary | |
| import gc | |
| import sys | |
| tracemalloc.start() | |
| collection = [] | |
| start = time.time() | |
| while time.time() < start + 60: | |
| key = int(time.time()) | |
| collection.append((key, list(range(1,1000)))) | |
| while len(collection) > 0 and collection[0][0] < time.time() - 10: | |
| print('pop') | |
| collection.pop() | |
| print("length of dict: {}".format(len(collection))) | |
| gc.collect() | |
| print(tracemalloc.get_traced_memory()) | |
| all_objects = pympler.muppy.get_objects() | |
| sum1 = pympler.summary.summarize(all_objects) | |
| pympler.summary.print_(sum1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment