Displaying heap memory occupation

mattia424
Posts: 13
Joined: Sun Jan 07, 2024 11:56 pm

Displaying heap memory occupation

Postby mattia424 » Sat Feb 10, 2024 4:11 pm

Hello, everyone,
I have noticed crashes in my ESP32 after several calls to the webserver using the httpd library.
I've also tried httpd_register_uri_handler a very simple function that only gives an HTTP 200 response and every time it receives a call the memory increments by about 300bytes this results in esp going into

Code: Select all

abort() was called at PC 0x420a16be on core 0
Setting breakpoint at 0x40377331 and returning...
Now I'm analysing the problem with the debugger but I can't figure out where the heap memory occupancy is checked.
I notice the memory increase with

Code: Select all

multi_heap_info_t info;
heap_caps_get_info(&info, MALLOC_CAP_INTERNAL); 
info.total_allocated_bytes
Is there any way to see the heap occupancy during debugging? would be the sum of the variables?

Thanks

MicroController
Posts: 1750
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Displaying heap memory occupation

Postby MicroController » Sat Feb 10, 2024 4:46 pm

https://docs.espressif.com/projects/esp ... debug.html

Do you get a backtrace output when the error happens?

Also,
and every time it receives a call the memory increments by about 300bytes this results in esp going into
300 bytes 'lost' per HTTP request? 30kb/100 requests? At that pace, it'd likely take hundreds of requests for the issue to become apparent. Are you sure this is what causes the abort() you're seeing?

mattia424
Posts: 13
Joined: Sun Jan 07, 2024 11:56 pm

Re: Displaying heap memory occupation

Postby mattia424 » Sat Feb 10, 2024 5:33 pm

Yes, I am quite sure that this is the problem.
I've tried replicating it by sending a lot of requests and in the process keeping track of the heap size and when it exceeds a certain threshold the abort happens. plus minus the threshold is always the same.
In the meantime I have carried out these tests I have stopped all other tasks not related to the network.

With the debugger connected I replicated the problem again and am now stopped at the point that generated the abort.
Unfortunately I don't have much experience with the debugger... try to see if the following information is sufficient to pinpoint the problem.
panicAbort.jpg
Debug
panicAbort.jpg (123.81 KiB) Viewed 599 times
In the meantime I'll try to see if I can get more information using the link you gave me.

Thanks

Who is online

Users browsing this forum: No registered users and 79 guests