Transferring big file #695
Replies: 5 comments 3 replies
-
You can do an HTTP POST in pieces. That's probably the easiest approach to getting a file from your device onto a web server. The httppoststreaming example shows how to make a single POST to a server using multiple fragments. That could be easily adapted to send a file instead. |
Beta Was this translation helpful? Give feedback.
-
Good morning Peter,
and it works, but unlucky, in my project, I have about 9 kB of free ram and from the XBug it seems that this function use about 20 kB and my app goes in Memory full. How can I reduce the Ram use? |
Beta Was this translation helpful? Give feedback.
-
This function, by itself, is likely not using 20 KB. Characterizing available memory requires more than a single number. There is the memory allocated to the JavaScript visual machine. As I recall, you have that set to a large number in your manifest. But, how much space is free in the slot and chunk heaps inside that? There is also system memory, which is separate from the slot and chunk heaps. That is used by native code, for example the Wi-Fi stack and lwip socket library. How much free system memory do you have? When the "out of memory" error occurs, is that in the slot, chunk, or system memory? Did you enable Wi-Fi for this function or was Wi-Fi already enabled? That matters because just turning on Wi-Fi consumes about 30 KB on the ESP32 with the current ESP-IDF. Each socket is relatively light, however, just a few KB typically. I believe your project uses a display. If that's true, you might benefit from updating your Moddable SDK. There is a commit from the last week that reduced the memory used by the SPI driver significantly. That will free up additional system memory, though it will not impact the slot or chunk heaps. If either of those is the source of the failure, the increased system memory is unlikely to make a difference. |
Beta Was this translation helpful? Give feedback.
-
The memory used by the file transfer is unlikely to be the issue. It is well optimized already. The memory used by your project before starting the file transfer is more likely the issue. A good starting point for reducing memory use inside the JavaScript virtual machine is to ensure that as many modules as possible are preloaded. If done properly, that can move the slots used by functions and classes from RAM into flash storage. |
Beta Was this translation helpful? Give feedback.
-
You have misunderstood. |
Beta Was this translation helpful? Give feedback.
-
In my app I created a file of about 125 kbyte.
Unfortunately I haven't memory enough to send it all together.
I can send it on "serial" or "ble" in small package, but is there is a way to upload it in FTP mode ?
Which is the simplest way to read it ?
Regards
Beta Was this translation helpful? Give feedback.
All reactions