WiFi Stack heap memory usage

Ankit Siddhapura
Posts: 21
Joined: Sat Jun 30, 2018 1:04 pm

WiFi Stack heap memory usage

Postby Ankit Siddhapura » Mon Aug 06, 2018 1:36 pm

Hi,

In my application, One RTOS task is continuously scanning AP records at delay of 1000 ms for RSSI value to be used for best parent choose.

After one or two hour STA got disconnected from connected AP duet to beacon time out and AP kicks off station.

i got below print before STA disconnect, seems out of memory.

I would like to know, how stack handles memory for beacon and probe response?

Code: Select all

[Fri Aug 03 20:14:02.074 2018] W (7450429) wifi: alloc eb len=196 type=2 fail
[Fri Aug 03 20:14:02.074 2018] 
[Fri Aug 03 20:14:02.074 2018] W (7450429) wifi: m f probe rsp l=169
[Fri Aug 03 20:14:02.074 2018] 
[Fri Aug 03 20:14:25.621 2018] I (7473979) wifi: bcn_timout,ap_probe_send_start
[Fri Aug 03 20:14:28.142 2018] I (7476479) wifi: ap_probe_send over, resett wifi status to disassoc
[Fri Aug 03 20:14:28.142 2018] I (7476479) wifi: state: run -> init (1)
[Fri Aug 03 20:14:28.142 2018] I (7476479) wifi: n:1 0, o:1 1, ap:1 1, sta:1 1, prof:1
[Fri Aug 03 20:14:28.142 2018] 
[Fri Aug 03 20:14:28.142 2018] STA disconnected
[Fri Aug 03 20:14:28.142 2018] 
[Fri Aug 03 20:14:28.142 2018] Reason code for STA disconnect :200
[Fri Aug 03 20:14:42.342 2018] STA disconnected
[Fri Aug 03 20:14:42.342 2018] 
[Fri Aug 03 20:14:42.342 2018] Reason code for STA disconnect :201
[Fri Aug 03 20:14:43.144 2018] 
[Fri Aug 03 20:14:43.144 2018] Number of access points found: 0
[Fri Aug 03 20:14:43.144 2018] 
[Fri Aug 03 20:14:43.144 2018] No AP available for this scan config, Start Scan Again

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: WiFi Stack heap memory usage

Postby kolban » Mon Aug 06, 2018 5:02 pm

Howdy. What are you seeing in the trace that leads you to believe memory utilization might be an issue?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: WiFi Stack heap memory usage

Postby WiFive » Mon Aug 06, 2018 7:48 pm

This

Code: Select all

[Fri Aug 03 20:14:02.074 2018] W (7450429) wifi: alloc eb len=196 type=2 fail

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: WiFi Stack heap memory usage

Postby ESP_Angus » Tue Aug 07, 2018 1:31 am

Hi Ankit,

In the default configuration, the WiFi stack will allocate buffers as needed from heap. There are some configuration settings you can change to adjust the allocation that is done, but I wouldn't start with that quite yet.

Is it possible your app has a memory leak? There are a number of functions you can use to check the amount of free heap over time, and a leak checker feature for narrowing down which part of the program is leaking.

If you have a memory leak then you'll see the free heap starting relatively high and then gradually trending down, until suddenly some allocations somewhere fail.

Ankit Siddhapura
Posts: 21
Joined: Sat Jun 30, 2018 1:04 pm

Re: WiFi Stack heap memory usage

Postby Ankit Siddhapura » Tue Aug 07, 2018 4:49 am

Thank You ! I got the issue and able to trace heap memory.

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: WiFi Stack heap memory usage

Postby Ritesh » Wed Aug 08, 2018 11:12 am

Ankit Siddhapura wrote:Thank You ! I got the issue and able to trace heap memory.
Hi Ankit,

Would you please describe issue like it is due to application or anything else so that other might know regarding this which might help in future?
Regards,
Ritesh Prajapati

Ankit Siddhapura
Posts: 21
Joined: Sat Jun 30, 2018 1:04 pm

Re: WiFi Stack heap memory usage

Postby Ankit Siddhapura » Wed Aug 08, 2018 1:11 pm

Hi Ankit,

Would you please describe issue like it is due to application or anything else so that other might know regarding this which might help in future?
Okay!

I was facing issue with beacon timeout and station disconnection with parent AP.
Among several reason for disconnection are if AP change its channel and switch to new channel at this time STA may get channel switch event. Another reason is Authentication mode change or STA miss N number of beacon then AP kicks off station from station list.

Here, I faced issue with memory leak, In my application missed to free dynamic allocated memory. So on every packet transmission heap memory decreased and when reached to <3000 bytes, stack generated beacon timeout because did not find sufficient memory to for probe response.

How I resolved the issue :
After several test I got doubt on memory leak. So, By tracing heap size using xPortGetFreeHeapSize() API i knew heap size is decreasing.
When it reached to less then around 3000 bytes issue reproduced. by fixing memory leak in application fixed this issue.

Thank You!

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: WiFi Stack heap memory usage

Postby Ritesh » Wed Aug 08, 2018 1:32 pm

Ankit Siddhapura wrote:
Hi Ankit,

Would you please describe issue like it is due to application or anything else so that other might know regarding this which might help in future?
Okay!

I was facing issue with beacon timeout and station disconnection with parent AP.
Among several reason for disconnection are if AP change its channel and switch to new channel at this time STA may get channel switch event. Another reason is Authentication mode change or STA miss N number of beacon then AP kicks off station from station list.

Here, I faced issue with memory leak, In my application missed to free dynamic allocated memory. So on every packet transmission heap memory decreased and when reached to <3000 bytes, stack generated beacon timeout because did not find sufficient memory to for probe response.

How I resolved the issue :
After several test I got doubt on memory leak. So, By tracing heap size using xPortGetFreeHeapSize() API i knew heap size is decreasing.
When it reached to less then around 3000 bytes issue reproduced. by fixing memory leak in application fixed this issue.

Thank You!
Thanks for update.
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: No registered users and 266 guests