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 Error, Memory Allocation Error of 136 bytes when trying import

    Scheduled Pinned Locked Moved SiPy
    2 Posts 2 Posters 44 Views 2 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.
    • CharlythonC Offline
      Charlython
      last edited by

      Im working with a SiPy board from pycom for a proyect, and all goes well untill i implemented 2 new files (that doesn't modify proyect behavior itself, but after uploading new files and trying to run my code, it shows a MemoryError: Memory allocation failed, allocating 136 bytes and i cant troubleshooting it. i tried a os.fsformat("/flash") to clean the board and upload again the proyect but i ended up with the same error, and walkaround the "error line" (just an import of another class that worked well) doesn't solve it, just found the same error later, in another import with different bytes allocated. I found something about frozen modules, but im junior software developer and don't wanna touch board firmware if i can avoid it.
      print("Thanks people")

      C 1 Reply Last reply Reply Quote 0
      • C Offline
        crumble @Charlython
        last edited by crumble

        @Charlython

        Your *.py files will be compiled on their first call. This needs time and memory. Depending on the size of source and the time you call it, memory me be too fragmented for compiling. You can use meminfo

        Sometimes it will help if you simply to import the files early.

        The better way to deal with this, is to precompile your source into *.mpy. Files will be shorter and memory fragmentation will be less. You can start with libraries you don't work on.

        You can compile the files into the firmware as frozen files. This will use less RAM than the precompiled files. IMHO it's not convenient.

        If you have really lllllaaaarrrrggggeeee files, you may write yourself a preprocessor to remove comments and to shorten variable and method names. But I don't expect that this will be necessary

        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