Page 1 of 1

Memory management primer

Posted: Tue Jul 05, 2022 12:33 pm
by APinto
Hello,

I am looking for a reference that explains how memory is managed with MicroPython on the ESP8266. I know the basic facts, that my D1 Mini has 4MB of flash and that the ESP8266 has 80KB of RAM. I know that I can check how much heap is available with gc.mem_free(). But I don't really know what factors are at play in terms of files in the flash, objects created, modules imported, etc. when I get out of memory errors. I searched in the forum but couldn't find anything. Does any of you have a link, please?

Thank you!

AP

Re: Memory management primer

Posted: Wed Jul 06, 2022 1:42 am
by jimmo
APinto wrote:
Tue Jul 05, 2022 12:33 pm
I am looking for a reference that explains how memory is managed with MicroPython on the ESP8266. I know the basic facts, that my D1 Mini has 4MB of flash and that the ESP8266 has 80KB of RAM. I know that I can check how much heap is available with gc.mem_free(). But I don't really know what factors are at play in terms of files in the flash, objects created, modules imported, etc. when I get out of memory errors. I searched in the forum but couldn't find anything. Does any of you have a link, please?
I did a talk at the Melbourne MicroPython Meetup a couple of years ago that covers a bunch of details about the GC with a particular focus on fragmentation and object layout. https://www.youtube.com/watch?v=H_xq8IYjh2w

This page from the docs might be helpful too https://docs.micropython.org/en/latest/ ... ained.html

This is a long (five page!) thread from a while ago that also has a lot of details viewtopic.php?f=2&t=7345

But also, feel free to ask questions and we can answer them. I'm actually working on the MicroPython docs this week, so it would be good to get some ideas for things to write about and improve.

Re: Memory management primer

Posted: Thu Jul 07, 2022 11:16 am
by APinto
Hello Jimmo, thank you! I'll try to get some questions I have today, and put there here.

AP