ESP-IDF Heap analyzation

tim687
Posts: 5
Joined: Thu Oct 26, 2023 4:51 pm

ESP-IDF Heap analyzation

Postby tim687 » Thu Oct 26, 2023 6:03 pm

Hi!

I'm wanting to analyze the memory usage of my app, since I think there are a few memory leaks. The app ultimately crashes whenever enough data has been parsed.

I've enabled the standalone memory analyzer, which wouldn't work as intended. Printing of the memory report took so long, that the ESP32 had an watchdog timeout, thus leaving the printed out message incomplete.

I decided to switch to host based memory analyzation, after quite some trouble, I got the debugger to work (platform-io doesn't support a custom partition table location when launching the debugger, so I had to manually fire everything up)
Whenever the debugger finally halts at the required functions, the heap output file is almost empty:

Code: Select all

;
; Version     SEGGER SystemViewer V2.42
; Author      Espressif Inc
;
Who can help me with this issue?

I'm starting openocd with:

Code: Select all

openocd -s "C:\esp-idf-5.0.1\tools\openocd-esp32\v0.11.0-esp32-20221026\openocd-esp32\share\openocd\scripts" -f interface/ftdi/esp32_devkitj_v1.cfg -f board/esp-wroom-32.cfg -c "init; halt; esp32 appimage_offset 0x20000"
I'm starting gdb with:

Code: Select all

xtensa-esp32-elf-gdb -x gdbinit .pio\build\debug\firmware.elf
My gdbinit file contains:

Code: Select all

target remote :3333

mon esp appimage_offset 0x20000
mon reset halt
flushregs

tb heap_trace_start
commands
mon esp sysview start file://heap.svdat
c
end

tb heap_trace_stop
commands
mon esp sysview stop
end

c

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP-IDF Heap analyzation

Postby ESP_Sprite » Fri Oct 27, 2023 3:01 am

FWIW, you can disable the watchdogs in Menuconfig.

tim687
Posts: 5
Joined: Thu Oct 26, 2023 4:51 pm

Re: ESP-IDF Heap analyzation

Postby tim687 » Sat Oct 28, 2023 10:36 am

I've managed to get it to work.

As the dump function was called in an execution speed sensitive context, I needed to raise the UART baudrate to get it to print fast enough.

Thanks!

Who is online

Users browsing this forum: No registered users and 102 guests