From 0f27c38855ef470374d8e6e20ecca3dc230d6086 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Fri, 12 Jul 2019 11:09:00 +1000 Subject: [PATCH] docs: Add notes about thread safety and using heap from ISRs Closes https://github.com/espressif/esp-idf/issues/3768 --- docs/en/api-reference/system/mem_alloc.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/en/api-reference/system/mem_alloc.rst b/docs/en/api-reference/system/mem_alloc.rst index cf6eb5020..d2e5222f4 100644 --- a/docs/en/api-reference/system/mem_alloc.rst +++ b/docs/en/api-reference/system/mem_alloc.rst @@ -113,6 +113,13 @@ API Reference - Heap Allocation .. include:: /_build/inc/esp_heap_caps.inc +Thread Safety +^^^^^^^^^^^^^ + +Heap functions are thread safe, meaning they can be called from different tasks simultaneously without any limitations. + +It is technically possible to call ``malloc``, ``free``, and related functions from interrupt handler (ISR) context. However this is not recommended, as heap function calls may delay other interrupts. It is strongly recommended to refactor applications so that any buffers used by an ISR are pre-allocated outside of the ISR. Support for calling heap functions from ISRs may be removed in a future update. + Heap Tracing & Debugging ------------------------