MemoryError: memory allocation failed, allocating %u bytes

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
User avatar
MorseIot
Posts: 38
Joined: Fri Jun 29, 2018 12:32 am

MemoryError: memory allocation failed, allocating %u bytes

Post by MorseIot » Sat Jul 14, 2018 10:37 pm

When you try to run file (test.py) with size of 18447 bytes, the error is generated:

Code: Select all

MemoryError: memory allocation failed, allocating %u bytes
When I split the same, it runs correctly. Is there any limitation of file size (py), or command that can bypass this situation

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: MemoryError: memory allocation failed, allocating %u bytes

Post by pythoncoder » Sun Jul 15, 2018 7:07 am

I suggest you read this part of the docs.
Peter Hinch
Index to my micropython libraries.

User avatar
MorseIot
Posts: 38
Joined: Fri Jun 29, 2018 12:32 am

Re: MemoryError: memory allocation failed, allocating %u bytes

Post by MorseIot » Sun Jul 15, 2018 9:13 pm

Thanks Peter Hinch, iam read the doc.

I need help using mpy-cross or use frozen bytecode

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: MemoryError: memory allocation failed, allocating %u bytes

Post by pythoncoder » Mon Jul 16, 2018 10:11 am

To use frozen bytecode you need to be able to build the firmware. Instructions are here. Once you can successfully build and flash a firmware build, freezing bytecode is done by putting your Python source in ports/esp8266/modules/, building and flashing.
Issuing

Code: Select all

>>> help('modules')
will list modules successfully frozen.
Peter Hinch
Index to my micropython libraries.

User avatar
MorseIot
Posts: 38
Joined: Fri Jun 29, 2018 12:32 am

Re: MemoryError: memory allocation failed, allocating %u bytes

Post by MorseIot » Tue Jul 17, 2018 3:04 pm

Ok

Thanks

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: MemoryError: memory allocation failed, allocating %u bytes

Post by Roberthh » Wed Jul 18, 2018 6:36 pm

Just in case you use Windows, I keep a version of mpy-cross.exe here: https://github.com/robert-hh/Shared-Stuff

User avatar
MorseIot
Posts: 38
Joined: Fri Jun 29, 2018 12:32 am

Re: MemoryError: memory allocation failed, allocating %u bytes

Post by MorseIot » Tue Jul 24, 2018 1:41 am

Thanks Roberthh

Post Reply