Memory management primer

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
APinto
Posts: 13
Joined: Fri Feb 25, 2022 11:47 am

Memory management primer

Post by APinto » Tue Jul 05, 2022 12:33 pm

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

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Memory management primer

Post by jimmo » Wed Jul 06, 2022 1:42 am

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.

APinto
Posts: 13
Joined: Fri Feb 25, 2022 11:47 am

Re: Memory management primer

Post by APinto » Thu Jul 07, 2022 11:16 am

Hello Jimmo, thank you! I'll try to get some questions I have today, and put there here.

AP

Post Reply