Memory Allocation Failed



  • I'm currently trying to use the WiPy 2.0 to run a Fast Fourier transform on around 1000 points. Because NumPy is not available in Pymakr, I wrote an FFT function using recursion. It works fairly well on a list of 512 points. However, when I increase the list to 1024 points and call my FFT function, I run into memory allocation errors within the function. Specifically, the error is "MemoryError: memory allocation failed, allocating 512 bytes".

    Is there anything I can do to fix this memory allocation problem? Does anyone have suggestions on a different implementation to perform an FFT that will use less memory?

    Any suggestions would be greatly appreciated, thanks!



  • @anikamanzo If you do not run the most recent version of the firmware, load that. The available stack was increased in version 1.6.9. You may also try to execute a gc.collect() at various points in your code, e.g. before you create larger memory objects. Besides that, you may look at other non-recursive implementations, like this one:
    https://github.com/peterhinch/micropython-fourier
    It uses ARM assembler in the core fucntions, but Peter also talks about a pure python implementation he tested. So you may address Peter directly and ask for a copy.


Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.