Unimporting a module to recover memory

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
cefn
Posts: 230
Joined: Tue Aug 09, 2016 10:58 am

Unimporting a module to recover memory

Post by cefn » Tue Mar 06, 2018 12:13 pm

Can a module be imported and then disposed of later to recover memory (assuming you ensure nothing has a reference to it) ?

Is it impossible, does it have to be forced, or is it simply a by-product of garbage collection following del(sys.modules['mymodule']) and assuming nothing else retains the reference?

My use case is where I have a series of tests with coverage of lots of different modules which I would like to run in sequence, but loading all the modules simultaneously is impossible given the limitations of the platform.

Post Reply