Difference between ESP.getFreeHeap() and xPortGetFreeHeapSize() ?

HankLloydRight
Posts: 7
Joined: Tue May 10, 2022 2:58 pm

Difference between ESP.getFreeHeap() and xPortGetFreeHeapSize() ?

Postby HankLloydRight » Wed May 11, 2022 7:42 pm

Hello,

I've been using xPortGetFreeHeapSize() in my project with a LOLIN32 V1.0.0 dev board and it's been working fine.

I tried upgrading my project to a LOLIN D32 PRO dev board with the exact same code (using Arduino framework on PIO), and now xPortGetFreeHeapSize() returns values around ~4,257,896 bytes instead of the ~100k range it was returning on the LOLIN32 board.

So I switched to ESP.getFreeHeap() instead, which seems to work, but on the LOLIN32 board, there's a constant 29,512 byte difference between the two function calls, with ESP.getFreeHeap() always being 29,512 bytes larger than xPortGetFreeHeapSize().

Any ideas why they would be different, and by this (seemingly fixed) amount?

Thank you.

lbernstone
Posts: 635
Joined: Mon Jul 22, 2019 3:20 pm

Re: Difference between ESP.getFreeHeap() and xPortGetFreeHeapSize() ?

Postby lbernstone » Thu May 12, 2022 2:54 am

xPortGetFreeHeapSize() is a synonym for esp_get_free_heap_size():
https://github.com/espressif/esp-idf/bl ... #L113-L116
The ESP call is asking for a slightly different set of memory:
https://github.com/espressif/arduino-es ... #L123-L128
You can see the difference between INTERNAL and DEFAULT in the heap_caps definition:
https://github.com/espressif/esp-idf/bl ... .h#L20-L37

HankLloydRight
Posts: 7
Joined: Tue May 10, 2022 2:58 pm

Re: Difference between ESP.getFreeHeap() and xPortGetFreeHeapSize() ?

Postby HankLloydRight » Thu May 12, 2022 10:53 am

lbernstone wrote:
Thu May 12, 2022 2:54 am
xPortGetFreeHeapSize() is a synonym for esp_get_free_heap_size():
https://github.com/espressif/esp-idf/bl ... #L113-L116
The ESP call is asking for a slightly different set of memory:
https://github.com/espressif/arduino-es ... #L123-L128
You can see the difference between INTERNAL and DEFAULT in the heap_caps definition:
https://github.com/espressif/esp-idf/bl ... .h#L20-L37
Wow, what a wealth of helpful information! Thank you so much.

Who is online

Users browsing this forum: pipi61 and 65 guests