1

I wonder if I create a large list, for example,

l = list(range(0, 10000000))

and then set it free for the garbage collector

l = None

it does not release all memory (according to memory_profiler):

Line #    Mem usage    Increment  Occurrences   Line Contents
=============================================================
     8    427.3 MiB    382.7 MiB           1       l = list(range(0, 10000000))
     9    122.3 MiB   -305.0 MiB           1       l = None

What is about the remainder?

Michael Dorner
  • 17,587
  • 13
  • 87
  • 117
  • 1
    Python doesn't necessarily release the memory back to the OS, even if it knows it's no longer using it. See e.g. https://stackoverflow.com/questions/15455048/releasing-memory-in-python. – jonrsharpe Jun 02 '22 at 09:19
  • How rude! :) Thanks for the comment. Maybe you would like to answer this to my question so that I can upvote your answer and mark it as answered. – Michael Dorner Jun 02 '22 at 09:28

0 Answers0