Files
esp-idf/components/esp_event/Kconfig
Jimmy Wennlund e2a6653680 feat(esp_event): Allow an event carry more data without malloc
This is both a feature and an optimization.

Feature:
Adjustable size of the internal storage in esp_event queue, currently
used by ISR posting, as they wont be able to make a malloc.

Optimization:
When non-isr is posting an event, use the inernal storage in the struct
instead of always allocating a new heap for the data. Most events in
esp-idf only contains a few bytes event information, and we have that
allocation payed for anyway.

This solved in a big part our memory fragmentation issue, as events
happens freqvently and used to create small memory allocations for just
4 bytes, and then in the event handler we usually allocated a bigger
chunk of heap for our feature. When returning from the event handler,
the 4 byte allocation was freed, leaving a hole in the heap.

Merges: https://github.com/espressif/esp-idf/pull/17797
2025-11-05 17:46:00 +02:00

48 lines
2.0 KiB
Plaintext

menu "Event Loop Library"
config ESP_EVENT_LOOP_PROFILING
bool "Enable event loop profiling"
default n
help
Enables collections of statistics in the event loop library such as the number of events posted
to/received by an event loop, number of callbacks involved, number of events dropped to to a full event
loop queue, run time of event handlers, and number of times/run time of each event handler.
config ESP_EVENT_POST_FROM_ISR
bool "Support posting events from ISRs"
default y
help
Enable posting events from interrupt handlers.
config ESP_EVENT_POST_FROM_ISR_SIZE
int "Max size of data from events (bytes)"
default 4
depends on ESP_EVENT_POST_FROM_ISR
range 4 256
help
Maximum size (in bytes) of event data that will be kept in the inline event
storage.
When ESP_EVENT_POST_FROM_ISR is enabled, event data with size less
than or equal to this value is copied into the fixed-size inline storage.
If event's data is larger than this limit, a heap allocation is performed
and the data is copied into the allocated buffer before posting.
When ESP_EVENT_POST_FROM_ISR is disabled, event data is always
copied to a heap-allocated buffer to ensure the data remains valid until the
event is processed.
Choose this value to trade static RAM footprint of the inline storage
against the frequency of heap allocations: smaller values reduce static
memory usage; larger values reduce heap allocations and fragmentation.
config ESP_EVENT_POST_FROM_IRAM_ISR
bool "Support posting events from ISRs placed in IRAM"
default y
depends on ESP_EVENT_POST_FROM_ISR
help
Enable posting events from interrupt handlers placed in IRAM. Enabling this option places API functions
esp_event_post and esp_event_post_to in IRAM.
endmenu