← index #9921PR #17030
Off-topic · high · value 2.621
QUERY · ISSUE

The memory of ESP32S3 is too large when using microython

openby Zhengqinze05opened 2022-11-11updated 2022-11-17
enhancement

I use the board of the ESP32. When I turn on microython, there will be more than 100 k of internal memory consumption. I have other functions to add. This more than 100 k of memory will cause me to run out of memory. What can I do to reduce the memory consumption of esp32 when using microython

CANDIDATE · PULL REQUEST

esp32/network_common: Raise a memory error on ESP_ERR_NO_MEM.

mergedby agattiopened 2025-03-28updated 2025-05-16
port-esp32

Summary

This PR changes the error handler for WiFi operations to recognise out of memory conditions reported by ESP-IDF functions, and report them as MemoryError exceptions rather than a generic "error 0x0101".

The error handler only provided a human-readable error description for WiFi-specific error codes (codes in the ESP_ERR_WIFI_BASE range), but WiFi functions are known to return other codes. Since an out of memory condition has a specific Python equivalent, using MemoryError in that case is a bit more user-friendly in exchange for a handful of extra code bytes used by the firmware.

Testing

The reproduction test case for #17027 was used to make sure an out of memory condition raised by the WiFi component was recognised as such.

Trade-offs and Alternatives

This change causes a minimal increase of the firmware size, which I believe is an acceptable trade-off from the user's point of view. After all, an out of memory error is not a "Wifi Unknown Error".

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied