With the below code I noticed that the board's memory space is decreasing while looping. Shouldn't the memory space remain the same?
TIA
Code: Select all
import machine, ssd1306, gc
from machine import I2C
from time import sleep
import esp
esp.osdebug(None)
i2c = I2C(scl=machine.Pin(4), sda=machine.Pin(5))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
def display_txt():
oled.fill(0)
#oled.text('MicroPython on', 0, 0)
#oled.text('an ESP32 with an', 0, 10)
#oled.text('attached SSD1306', 0, 20)
txt = 'free mem: {}'.format(gc.mem_free())
oled.text(txt, 0, 0)
oled.show()
try:
while True:
display_txt()
sleep(0.05)
#print('mem free: {}'.format(gc.mem_free()))
except OSError as e:
print(e)
mem free: 113184
mem free: 113024
mem free: 112864
mem free: 112704
mem free: 112544
.......
mem free: 464
mem free: 336
mem free: 208
mem free: 80
mem free: 116272
mem free: 116112
mem free: 115952