Memory allocation error allready!?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Oraclejosh333
- Posts: 10
- Joined: Wed Nov 16, 2022 2:41 pm
Memory allocation error allready!?
Hello friends, so im just learning to use circuitpython and Mu to load the basic L.E.D animations from the adafruit website in the tutorial by Kattni Rembor. Was gaining confidence until i started getting the memory error. Surely its not out of space with a basic L.E.D animation code. Code says MemoryError: memory allocation failed, allocating 61 bytes. I have the updated circuit python library. Please help!! Its only 57 lines of code
- dastels
- Posts: 15667
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Memory allocation error allready!?
What board are you using? A CircuitPlayground Express? What libraries/modules? What version of CircuitPython?
Dave
Dave
- Oraclejosh333
- Posts: 10
- Joined: Wed Nov 16, 2022 2:41 pm
Re: Memory allocation error allready!?
Hi, its a brand new cpx board with the current library bundle and running circuitpython 7
- dastels
- Posts: 15667
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Memory allocation error allready!?
Ah. The SAMD21 used on the CPX doesn't have much RAM. CircuitPython code is stored in RAM. That includes any modules you import as well (and any they import etc). CircuitPython continuously uses (and gives back when it's done with it) RAM as the code runs. The result is that the CPX fills up fast.
I advise you upgrade to a board with an MCU that has more RAM, The SAMD51, nRF52840 (the CircuitPlayground Bluefruit has the same size/shape/capabilities as the CPX, plus Bluetooth, more RAM, and is faster), ESP32-S3, or RP2040 are all good choices.
Your other option is to switch to C++/Arduino. Compiled C++ code is stored in Flash memory and not RAM.
Dave
I advise you upgrade to a board with an MCU that has more RAM, The SAMD51, nRF52840 (the CircuitPlayground Bluefruit has the same size/shape/capabilities as the CPX, plus Bluetooth, more RAM, and is faster), ESP32-S3, or RP2040 are all good choices.
Your other option is to switch to C++/Arduino. Compiled C++ code is stored in Flash memory and not RAM.
Dave
- Oraclejosh333
- Posts: 10
- Joined: Wed Nov 16, 2022 2:41 pm
Re: Memory allocation error allready!?
Thats pretty dissapointing. I bought this thing to make basic animations and it doesnt even have room for it then. Was trying to build a proper led wizard staff. I think im throwing in the towel, in over my head as it is and out of fun money. Why would they fill the cpx full of led's when it doesnt have ram to even run a basic color cycle code. Thanks for the info dave.
- dastels
- Posts: 15667
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Memory allocation error allready!?
As I mentioned, you can use C++/Arduino. There's never worry about space with that.
Things with CircuitPython have changed a lot since the CPX was released.
Dave
Things with CircuitPython have changed a lot since the CPX was released.
Dave
- dastels
- Posts: 15667
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Memory allocation error allready!?
Actually, MakeCode is another alternative that I always forget. [See url]https://learn.adafruit.com/glowing-inte ... stal-staff[/url], https://learn.adafruit.com/makecode, and https://learn.adafruit.com/adafruit-cir ... s/makecode.
Dave
Dave
- Oraclejosh333
- Posts: 10
- Joined: Wed Nov 16, 2022 2:41 pm
Re: Memory allocation error allready!?
Oh hey great idea with makecode. I dont know much about c++ arduino. Probaly over my head. Im gonna mess around with makecode until i can buy a better board. Thanks so much dave.
Please be positive and constructive with your questions and comments.