Memory allocation error allready!?

Play with it! Please tell us which board you're using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Oraclejosh333
 
Posts: 10
Joined: Wed Nov 16, 2022 2:41 pm

Memory allocation error allready!?

Post by Oraclejosh333 »

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

User avatar
dastels
 
Posts: 15658
Joined: Tue Oct 20, 2015 3:22 pm

Re: Memory allocation error allready!?

Post by dastels »

What board are you using? A CircuitPlayground Express? What libraries/modules? What version of CircuitPython?

Dave

User avatar
Oraclejosh333
 
Posts: 10
Joined: Wed Nov 16, 2022 2:41 pm

Re: Memory allocation error allready!?

Post by Oraclejosh333 »

Hi, its a brand new cpx board with the current library bundle and running circuitpython 7

User avatar
dastels
 
Posts: 15658
Joined: Tue Oct 20, 2015 3:22 pm

Re: Memory allocation error allready!?

Post by dastels »

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

User avatar
Oraclejosh333
 
Posts: 10
Joined: Wed Nov 16, 2022 2:41 pm

Re: Memory allocation error allready!?

Post by Oraclejosh333 »

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.

User avatar
dastels
 
Posts: 15658
Joined: Tue Oct 20, 2015 3:22 pm

Re: Memory allocation error allready!?

Post by dastels »

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

User avatar
dastels
 
Posts: 15658
Joined: Tue Oct 20, 2015 3:22 pm

Re: Memory allocation error allready!?

Post by dastels »


User avatar
Oraclejosh333
 
Posts: 10
Joined: Wed Nov 16, 2022 2:41 pm

Re: Memory allocation error allready!?

Post by Oraclejosh333 »

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.

Locked
Please be positive and constructive with your questions and comments.

Return to “Circuit Playground Classic, Circuit Playground Express, Circuit Playground Bluefruit”