I’m not saying your approach is wrong or right but if it has any chance of working, you have to call gc.collect() are you call delkevinkk525 wrote:I'm having problems with unloading modules, the RAM does not get freed.
I'm using this function to delete a module:I am importing a module and call one function. Then I delete it like that:Code: Select all
def unloadModule(mod): # removes module from the system mod_name = mod.__name__ if mod_name in sys.modules: del sys.modules[mod_name]
But the RAM is only a small amount higher than with the module imported, far away from the free RAM before I imported the module.Code: Select all
from pysmartnode.helpers import helper helper.help() unloadModule(helper) del helper
del by itself just removes an entry from the dict.
If you want the memory it used to point to to be freed, you have to call gc.collect()
However I’m not guaranteeing your approach will actually free the memory; gotta look at the C source code.