RangerDigital / senko

🦊 Simplest OTA update solution for your Micropython projects.
GNU General Public License v3.0
95 stars 21 forks source link

MemoryError: memory allocation failed #7

Closed chaseadam closed 1 year ago

chaseadam commented 1 year ago

I noted this was originally written for targets including ESP32, but I am having trouble with memory allocation errors on micropython 1.19.1 (possibly older versions as well). It chokes on py files less than 26KB.

>>> OTA.fetch()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/lib/senko.py", line 74, in fetch
  File "/lib/senko.py", line 53, in _check_all
  File "/lib/senko.py", line 45, in _get_file
  File "urequests.py", line 28, in text
  File "urequests.py", line 20, in content
MemoryError: memory allocation failed, allocating 12288 bytes

I have had some success in the past using gc.collect() to help remedy memory allocation failures and even modified the _get_file() method to collect before the urequests.get(). SSL connections (using mbedTLS) has severe limitations with micropython due to limited IDF heap available and even is unusable in later versions of the ESP IDF due to memory allocation behavior (https://github.com/micropython/micropython/issues/8940).

From what I can tell, this is not IDF heap related and I am running out of python memory. I moved the senko check in boot.py (before main application imports and init) and it is functioning as expected without error.