On Friday, December 15, 2017 at 6:51:37 AM UTC-8, Marco Caselli wrote: > > Thank you very much for your prompt replies. I was sure that range(n) > creates an iterator instead of the list itself, my bad. > In any case, even if the function is creating this list, why is it still > stored in memory after the function terminates? It is a local variable, and > is not returned so it should be erased from the RAM. >
And undoubtedly it did (a list of integers has no circular references, so it can be deleted just based on reference counts), but obtaining memory from and returning memory to the operating system is an expensive operation, so python is probably reluctant to do so. get_memory_usage only reports how much memory is allocated to the python process, not how much of it python is actually considering as in use. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.