Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Audio on nRF52840 with low or fragmented memory
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Audio on nRF52840 with low or fragmented memory

by kevinjwalters on Thu Jul 02, 2020 11:25 am

I've been seeing some of these recently in CircuitPython 5.3.0 running with about 45k spare as reported by gc.mem_free():

Code: Select all | TOGGLE FULL SIZE
MemoryError: memory allocation failed, allocating 2048 bytes


and

Code: Select all | TOGGLE FULL SIZE
MemoryError: memory allocation failed, allocating 1784 bytes


I think those sporadic exceptions originate from PWMAudioOut.play and adding entries to a Dict, respectively.

If anyone else is suffering from the first 2048 byte one due to playing audio, I've written a class which offers some workarounds to avoid leaving the interal buffer de-allocated, see rps_audio.py.

kevinjwalters
 
Posts: 674
Joined: Sun Oct 01, 2017 3:15 pm

Please be positive and constructive with your questions and comments.