CRITICAL: machine.reset() not releasing the memory



  • It is amazing that after you reset the board with machine.reset(), and the main.py is executed again, the memory seems to be not available for loading modules, despite the fact mem_free() is showing that 54xxx bytes. If you are pressing the reset button similar behviour. Only if you are unplug power and plug it will resolve the memory issue .

    How you can test this: put your script in main.py. The script has to load (your) modules that eats progressively the memory. You catch in a try the exception 'memory allocation failed, allocating xxxx bytes' then trigger the machine.reset(). After boot the same script is executed and rise exception due to same memory issue.

    Try to connect as STA to Imalog
    I (8361) wifi: ap channel adjust o:1,1 n:4,1
    I (8361) wifi: n:4 1, o:1 0, ap:4 1, sta:4 1, prof:1
    I (9336) wifi: state: init -> auth (b0)
    I (9338) wifi: state: auth -> assoc (0)
    I (9344) wifi: state: assoc -> run (10)
    I (9354) wifi: connected with Imalog, channel 4
    Exception: memory allocation failed, allocating 2373 bytes
    I (11550) wifi: state: run -> init (0)
    I (11551) wifi: n:4 0, o:4 1, ap:4 1, sta:4 1, prof:4
    ets Jun 8 2016 00:22:57

    rst:0xc (SW_CPU_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0x00
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:QIO, clock div:2
    load:0x3fff9010,len:8
    load:0x3fff9018,len:248
    load:0x40078000,len:4056
    load:0x4009f000,len:920
    entry 0x4009f1e4
    tcpip_task_hdlxxx : 3ffd5190, prio:18,stack:2048
    I (2757) wifi: frc2_timer_task_hdl:3ffd87d8, prio:22, stack:2048
    I (2762) wifi: pp_task_hdl : 3ffdb088, prio:23, stack:8192
    I (2763) wifi: sleep disable
    I (3737) wifi: mode : softAP (24:0a:c4:00:0a:b9)
    dhcp server start:(ip: 192.168.4.1, mask: 255.255.255.0, gw: 192.168.4.1)
    LocalTime: (1970, 1, 1, 0, 0, 1, 3, 1)
    ScsFromEpoch: 1
    config {'w': {'ap': 'xxda', 'sp': '!!qa', 'ss': 'Imalog', 'aa': 3, 'as': 'pyc', 'sa': 3}, 't': [{'g': True, 'p': 9999, 'a': '192.168.20.49'}]}
    WLAN STA+AP mode as ap12061184 with ap00a08b
    I (6776) wifi: sleep disable
    I (7753) wifi: mode : sta (24:0a:c4:00:0a:b8) + softAP (24:0a:c4:00:0a:b9)
    dhcp server start:(ip: 192.168.4.1, mask: 255.255.255.0, gw: 192.168.4.1)
    Try to connect as STA to Imalog
    I (8352) wifi: ap channel adjust o:1,1 n:4,1
    I (8352) wifi: n:4 1, o:1 0, ap:4 1, sta:4 1, prof:1
    I (9327) wifi: state: init -> auth (b0)
    I (9329) wifi: state: auth -> assoc (0)
    I (9335) wifi: state: assoc -> run (10)
    I (9346) wifi: connected with Imalog, channel 4
    Exception: memory allocation failed, allocating 2373 bytes
    I (11539) wifi: state: run -> init (0)
    I (11540) wifi: n:4 0, o:4 1, ap:4 1, sta:4 1, prof:4
    ets Jun 8 2016 00:22:57



Pycom on Twitter