Geekything
Geekything

Reputation: 11

ESP 8266 micropython can't allocate memory

I'm a complete newbie to Micropython on the ESP8266 and I can't seem to find an answer to why I can't allocate memory for a library.

The REPL output is:

Traceback (most recent call last):
  File "main.py", line 2, in <module>
MemoryError: memory allocation failed, allocating 1152 bytes

My meminfo looks like this:

>>> micropython.mem_info(1)
stack: 2128 out of 8192
GC: total: 35968, used: 11952, free: 24016
 No. of 1-blocks: 36, 2-blocks: 10, max blk sz: 264, max free sz: 185
GC memory layout; from 3ffef550:
00000: MDhhhBMMDDSMhDDB=BBBh===h====hMhhh==h===========================
00400: ================================================================
00800: ================================================================
00c00: ================================================================
01000: ============================================ThhDBBBBBBh===hB=h=h
01400: ===B=h==h=B...h========h=.h=======h=============================
01800: ================================================================
01c00: ================================================================
02000: ====================================================h.h==hh==..h
02400: =h=.............h=======..............................h=======..
02800: ......h=======......h=======...................................h
02c00: ===========.....................................................
03000: ................................................................
03400: .........................................h=======...............
03800: .h======......................h=======..........................
03c00: ...............h=======.........................................
04000: .................................................h=======.......
       (2 lines all free)
04c00: ..................................................h=======......
05000: .................................h=======.......................
05400: ................................................................
05800: .........h=======...............................................
05c00: .........................................................h======
06000: =...............................................................
06400: ...............h=======.........................................
06800: ................................h=======........................
06c00: ..............................h=======..........................
07000: ................................................................
07400: ......h=======..................................................
07800: .h=======.......................................................
07c00: .h=h=...........................................................
08000: .......h=======.................................................
08400: ....................................................h=======....
08800: ................................................................
08c00: ........
>>> 

Unless I'm misunderstanding, this shows some 2K blocks available?

A garbage collection yields the following:

>>> import gc
>>> import micropython
>>> gc.collect()
>>> micropython.mem_info()
stack: 2112 out of 8192
GC: total: 35968, used: 11856, free: 24112
 No. of 1-blocks: 32, 2-blocks: 11, max blk sz: 264, max free sz: 185
>>> 

Am I doing something fundamentally wrong here?

Upvotes: 1

Views: 2238

Answers (1)

yousef negahdari
yousef negahdari

Reputation: 59

Your main.py is located on flashROM.and the script is using whole flash memory but you have to use freezing memory(E2PROM),which means the binary framework was compiled to the esp8266.

check that in frozen Module

Upvotes: 2

Related Questions