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