0

Is there any way to release the memory by deleting the modules that have been imported in the script.

I have checked many articles, somebody says python does not have the functionality. However, others show some method to do that. Finally, I found those answers are quite misleading.

Use pandas as an example. I tried: Approach 1:

del pandas

Result 1: you cannot call pandas anymore, but the memory has not been released.

Approach 2:

import sys
modules = sys.modules() #this return a dict
del modules['some module key']

Result 2: you cannot call the module anymore, the same is that the memory has not been released.

Some packages like pandas are very useful but very heavy. I want to release the memory if I no longer need them. Thanks in advance for any hint.

Yuan
  • 462
  • 4
  • 12
  • As explained here, this is not possible https://stackoverflow.com/a/8781273/11220780 – Benoit de Menthière Aug 02 '19 at 06:50
  • @BenoitdeMenthière I read that article before. I think that was misleading. It did not give any reason why that happened and that article was written 10 years before. Any morden solution in 2019? – Yuan Aug 02 '19 at 06:55

0 Answers0