如何在 ESP32 上使用 vPortGetHeapStats()?

问题:

编译 ESP32 项目时,你看到类似以下错误消息

compile_error_output.txt
src/main.cpp:128:3: error: 'vPortGetHeapStats' was not declared in this scope
    vPortGetHeapStats(&heapStats);

解决方案

虽然 vPortGetHeapStats() 通常在 freertos/portable.h 中定义,你不能在 ESP32 上使用 vPortGetHeapStats(),因为框架不使用 FreeRTOS 堆实现。

要查找有关堆使用的信息,使用 ESP heap APIesp_get_free_heap_size()


Check out similar posts by category: ESP8266/ESP32, FreeRTOS