How to clear all scripts in mp

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
cduran
Posts: 80
Joined: Thu Mar 17, 2016 4:52 pm

How to clear all scripts in mp

Post by cduran » Tue Apr 18, 2017 5:12 pm

I'm currently using micropython to execute scripts that are sent over the air to my device. The scripts are kept in FLASH until its time for their execution by mp. What I would like to do is after a script executes, remove it from RAM. Is there a function for removing mp scripts from the heap?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: How to clear all scripts in mp

Post by Roberthh » Tue Apr 18, 2017 6:34 pm

The list of all loaded modules is kept in the dictionary sys.modules. if 'my_module' has been loaded, you'll find it in that list. You can remove it from that module with

Code: Select all

del sys.modules['my_module']
The, you can load that module again. But I analysed, whether that frees RAM..

Post Reply