Page 1 of 1

ESP-IDF Heap analyzation

Posted: Thu Oct 26, 2023 6:03 pm
by tim687
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

Re: ESP-IDF Heap analyzation

Posted: Fri Oct 27, 2023 3:01 am
by ESP_Sprite
FWIW, you can disable the watchdogs in Menuconfig.

Re: ESP-IDF Heap analyzation

Posted: Sat Oct 28, 2023 10:36 am
by tim687
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!