fix(heap): revert DMA pool MALLOC_CAP_DEFAULT caps

This commit is contained in:
wuzhenghui
2026-08-27 19:46:48 +08:00
parent d41a3436b1
commit 68eea51d27
6 changed files with 31 additions and 26 deletions

View File

@@ -104,14 +104,7 @@ An additional configuration item, :ref:`CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL`, ca
If a suitable block of preferred internal/external memory is not available, the allocator will try the other type of memory.
Because some buffers can only be allocated in internal memory, a second configuration item :ref:`CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL` reserves a pool of internal DMA-capable memory at startup (in ``main_task``, after PSRAM is initialized). The pool is malloc from the regular internal heaps and re-registered as separate heap pool.
The reserved pool uses the heap capability priority mechanism:
- **Medium priority**``MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL``: explicit ``heap_caps_malloc()`` requests with these flags are preferentially served from this pool.
- **Low priority**``MALLOC_CAP_DEFAULT``: ``malloc()`` may use the pool only after other internal heaps with higher-priority ``MALLOC_CAP_DEFAULT`` are exhausted.
Therefore, under normal conditions ``malloc()`` does not allocate from this pool, but it can fall back to it as a last resort before allocation fails entirely.
Because some buffers can only be allocated in internal memory, a second configuration item :ref:`CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL` defines a pool of internal memory which is reserved for *only* explicitly internal allocations (such as memory for DMA use). Regular ``malloc()`` will not allocate from this pool. The :ref:`MALLOC_CAP_DMA <dma-capable-memory>` and ``MALLOC_CAP_INTERNAL`` flags can be used to allocate memory from this pool.
.. _external_ram_config_bss:

View File

@@ -104,14 +104,7 @@ ESP-IDF 启动过程中,片外 RAM 被映射到数据虚拟地址空间,该
如果优先考虑的内部或外部存储器中没有可用的存储块,分配程序则会选择其他类型存储。
由于有些内存缓冲器仅可在内部存储器中分配,因此需要使用第二个配置项 :ref:`CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL` 在启动阶段PSRAM 初始化完成后,于 ``main_task`` 中)预留一块内部 DMA 可用内存池。该内存从常规内部堆中分配出,并重新注册为独立的内存池
预留池通过堆能力优先级机制管理:
- **中优先级**``MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL``:显式使用这些标志的 ``heap_caps_malloc()`` 请求会优先从此池分配。
- **低优先级**``MALLOC_CAP_DEFAULT``:仅当其他具有更高优先级 ``MALLOC_CAP_DEFAULT`` 的内部堆耗尽后,``malloc()`` 才会回退使用此池。
因此,在正常情况下 ``malloc()`` 不会从该池分配;仅当其他内部内存耗尽后,``malloc()`` 才会将其作为最后的回退来源以避免分配完全失败。
由于有些内存缓冲器仅可在内部存储器中分配,因此需要使用第二个配置项 :ref:`CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL` 定义一个内部内存池,仅限显式的内部存储器分配使用(例如用于 DMA 的存储器)。常规 ``malloc()`` 将不会从该池中分配,但可以使用 :ref:`MALLOC_CAP_DMA <dma-capable-memory>```MALLOC_CAP_INTERNAL`` 标志从该池中分配存储器
.. _external_ram_config_bss: