send_file with > 500kb ends with MemoryError: memory allocation failed, allocating 1025 bytes #121
-
Hi, I've cross-compiled the latest microdot source into the micropython firmware and I'm using an esp8266 with 4MB If I run my app and load the index.html the output is
Here are part's of the code
Is it a problem with the file size? As far as I read, micro. is sending big files in chunks. Can you please give me a hint what's wrong? It is possible that the browser is parallel-loading the needed files (main.js, styles.css, polyfills.js, runtime.js) and that there are 4 parallel requests to deliver files and that's too much for the esp? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It cannot be a problem with file size, because as you've discovered, files are sent in fixed-size chunks. But if you get a few concurrent requests I guess it is possible that you are running out of memory. Can you try adding this at the top of your server file? from microdot_asyncio import Response
Response.send_file_buffer_size = 256 The default is 1024 bytes for each file chunk. Hopefully you can find a size that allows all your static file requests to go through. Unfortunately the server can still blow up if two clients connect at the same time though. |
Beta Was this translation helpful? Give feedback.
It cannot be a problem with file size, because as you've discovered, files are sent in fixed-size chunks. But if you get a few concurrent requests I guess it is possible that you are running out of memory.
Can you try adding this at the top of your server file?
The default is 1024 bytes for each file chunk. Hopefully you can find a size that allows all your static file requests to go through. Unfortunately the server can still blow up if two clients connect at the same time though.