为什么重新分配会导致内存泄漏?

时间:2021-01-27 01:08:05

标签: memory-leaks jupyter-notebook python-3.7

在 jupyter notebook 中多次运行这个单元会导致内存泄漏。我不明白为什么。

my_list = list(map(lambda x: [1,2,3,4,4,4,4,4,4,4,4,4,4,4], range(300000)))

如果我运行以下单元格一次:

my_list = list(map(lambda x: [1,2,3,4,4,4,4,4,4,4,4,4,4,4], range(300000)))
my_list = list(map(lambda x: [1,2,3,4,4,4,4,4,4,4,4,4,4,4], range(300000)))
my_list = list(map(lambda x: [1,2,3,4,4,4,4,4,4,4,4,4,4,4], range(300000)))
my_list = list(map(lambda x: [1,2,3,4,4,4,4,4,4,4,4,4,4,4], range(300000)))
my_list = list(map(lambda x: [1,2,3,4,4,4,4,4,4,4,4,4,4,4], range(300000)))
my_list = list(map(lambda x: [1,2,3,4,4,4,4,4,4,4,4,4,4,4], range(300000)))

这样就不会出现内存泄漏了。所以我认为问题在于 jupyer notebook 如何管理单元格运行之间的引用和内存。
python3.7 Linux Mint 18.3

0 个答案:

没有答案