MemoryError on Pico eventhough free memory is sufficient #12577
Replies: 5 comments 10 replies
-
This can occur due to RAM fragmentation. If the application requires N contiguous bytes it will fail if the largest block of free space is smaller than that. In some cases calling |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply. This sounds reasonable. In fact I am suspecting my web server implementation to be the root cause of the fragmentation. It receives a buffer of data each time an HTTP request is made from a client and processes it. Here is a code snippet which receives the request from a socket:
I am not sure if the |
Beta Was this translation helpful? Give feedback.
-
It should be possible to re-use a buffer. Instantiate a buffer big enough to accept the longest response. Declare the buffer early in execution, before fragmentation has set in. You also need a You can use |
Beta Was this translation helpful? Give feedback.
-
To be able to use the This works: This times out: What am I missing? Any idea? |
Beta Was this translation helpful? Give feedback.
-
The documentation of read() and readinto() is a bit confusing to me:
So if the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Sometimes I get a
MemoryError
exception on the Pico, saying that it cannot allocate N bytes. But when checking the available memory withgc.mem_free()
it reports more free memory than what is needed. Typically this happens when using the networking functions from theusocket
package.Someone has an explanation for this?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions