ESP_ERR_NO_MEM (0x101) on the ESP32

An ESP-IDF function could not allocate the memory it needed. The total free heap is often not the problem: the largest free block is.

ESP_ERROR_CHECK failed: esp_err_t 0x101 (ESP_ERR_NO_MEM) at 0x400d2a4f
file: "./main/main.c" line 42
func: app_main
expression: …

ESP_ERR_NO_MEM (0x101). ESP-IDF's description: Out of memory.

Measure the right numbers

The usual causes

A leak usually shows up in the field days after shipping. Pinscope records each device's free heap over time, so a slow leak is a falling line before it is a crash: heap and stack monitoring.

Related errors: ESP_ERR_NVS_NO_FREE_PAGES · ESP_ERR_INVALID_STATE · esp_err_t codes. All ESP32 errors: the list. Codes and descriptions from ESP-IDF's headers; behaviour from the API documentation of the functions named. ESP-IDF's Error Handling guide.

More