Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Memory Allocation Failed

    Scheduled Pinned Locked Moved WiPy 2&3
    wipy2.0pymakrfftnumpy
    6 Posts 3 Posters 2.2k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      anikamanzo
      last edited by

      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!

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @anikamanzo
        last edited by

        @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.

        1 Reply Last reply Reply Quote 0
        • P Offline
          pwest
          last edited by

          I desire to use an FFT in an application that I'm working on and I am amazed to find that a search of this entire forum reveals this post as the only one containing 'FFT'. The single reply vectoring me to the excellent work of Peter Hinch leads me to this dialog: https://github.com/peterhinch/micropython-fft/issues/1 where the topic of getting a fast FFT on the ESP32 is discussed, ultimately with a bleak outlook.

          Any advice on how to proceed would be appreciated.

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @pwest
            last edited by

            @pwest Using a PyCom module with 4MB RAM, you should be able to use a standard python implementation, if the speed does not matter.. A search on the Internet reveals standalone implementations not based on NumPy,

            P 1 Reply Last reply Reply Quote 0
            • P Offline
              pwest @robert-hh
              last edited by

              @robert-hh

              Thanks for the input. Speed matters, but even a slow FFT would be useful, at least for proof of concept, sensitivity and calibration. Unfortunately, I've got several WiPy 2.0 boards, which I understand only have 512kb of memory.

              robert-hhR 1 Reply Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @pwest
                last edited by

                @pwest memory is even lower. They have about 40k heap for Python objects, including the byte code.

                1 Reply Last reply Reply Quote 0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • 1 / 1
                • First post
                  Last post

                Pycom on Twitter

                Pycom