I set up the wifi_shell sample using a nRF7002DK and noticed that it is leaking 104 bytes of heap after each wifi connect/disconnect cycle. This is with version 2.7.0 of the SDK.
Here is how to reproduce.
- Setup a new project on the nRF7002DK using the wifi_shell sample.
- Modify proj.conf to add CONFIG_SYS_HEAP_RUNTIME_STATS=y
- Use the shell commands "connect" and "disconnect" to connect and disconnect to a wifi network
- Use the "kernel heap" command to check the heap usage
- Repeat steps 3 and 4 and observe that the heap usage is increasing by 104 bytes every cycle
Here is my output from the shell during the test. The only other change I made to the sample was to enable RTT.
rtt:~$ wifi connect -s mySSID -p myPassword -k 1 Connection requested rtt:~$ Connected [00:01:24.631,683] <inf> wpa_supp: nordic_wlan0: SME: Trying to authenticate with a0:36:bc:b7:31:51 (SSID='mySSID' freq=2452 MHz) rtt:~$ [00:01:24.888,397] <inf> wpa_supp: nordic_wlan0: Trying to associate with a0:36:bc:b7:31:51 (SSID='mySSID' freq=2452 MHz) rtt:~$ [00:01:24.907,806] <inf> wpa_supp: nordic_wlan0: Associated with a0:36:bc:b7:31:51 rtt:~$ [00:01:24.907,989] <inf> wpa_supp: nordic_wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0 rtt:~$ rtt:~$ [00:01:24.927,947] <inf> wpa_supp: nordic_wlan0: WPA: Key negotiation completed with a0:36:bc:b7:31:51 [PTK=CCMP GTK=CCMP] rtt:~$ [00:01:24.928,253] <inf> wpa_supp: nordic_wlan0: CTRL-EVENT-CONNECTED - Connection to a0:36:bc:b7:31:51 completed [id=0 id_str=] rtt:~$ [00:01:24.949,310] <inf> net_dhcpv4: Received: 192.168.50.78 rtt:~$ rtt:~$ wifi disconnect Disconnection request done (0) Disconnect requested rtt:~$ [00:01:36.689,208] <inf> wpa_supp: nordic_wlan0: CTRL-EVENT-DISCONNECTED bssid=a0:36:bc:b7:31:51 reason=3 locally_generated=1 rtt:~$ [00:01:36.695,800] <inf> wpa_supp: nordic_wlan0: CTRL-EVENT-DSCP-POLICY clear_all rtt:~$ rtt:~$ kernel heap free: 16644 allocated: 62796 max. allocated: 68088 rtt:~$ wifi connect -s mySSID -p myPassword -k 1 Connection requested rtt:~$ Connected [00:02:02.580,139] <inf> wpa_supp: nordic_wlan0: SME: Trying to authenticate with a0:36:bc:b7:31:51 (SSID='mySSID' freq=2452 MHz) rtt:~$ [00:02:02.613,891] <inf> wpa_supp: nordic_wlan0: Trying to associate with a0:36:bc:b7:31:51 (SSID='mySSID' freq=2452 MHz) rtt:~$ [00:02:02.644,622] <inf> wpa_supp: nordic_wlan0: Associated with a0:36:bc:b7:31:51 rtt:~$ [00:02:02.644,805] <inf> wpa_supp: nordic_wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0 rtt:~$ rtt:~$ [00:02:02.666,107] <inf> wpa_supp: nordic_wlan0: WPA: Key negotiation completed with a0:36:bc:b7:31:51 [PTK=CCMP GTK=CCMP] rtt:~$ [00:02:02.666,351] <inf> wpa_supp: nordic_wlan0: CTRL-EVENT-CONNECTED - Connection to a0:36:bc:b7:31:51 completed [id=0 id_str=] rtt:~$ [00:02:02.696,380] <inf> net_dhcpv4: Received: 192.168.50.78 rtt:~$ rtt:~$ wifi disconnect Disconnection request done (0) Disconnect requested rtt:~$ [00:02:10.308,013] <inf> wpa_supp: nordic_wlan0: CTRL-EVENT-DISCONNECTED bssid=a0:36:bc:b7:31:51 reason=3 locally_generated=1 rtt:~$ [00:02:10.312,835] <inf> wpa_supp: nordic_wlan0: CTRL-EVENT-DSCP-POLICY clear_all rtt:~$ rtt:~$ kernel heap free: 16520 allocated: 62900 max. allocated: 68192 rtt:~$ wifi connect -s mySSID -p myPassword -k 1 Connection requested rtt:~$ Connected [00:02:55.350,830] <inf> wpa_supp: nordic_wlan0: SME: Trying to authenticate with a0:36:bc:b7:31:51 (SSID='mySSID' freq=2452 MHz) rtt:~$ [00:02:55.358,276] <inf> wpa_supp: nordic_wlan0: Trying to associate with a0:36:bc:b7:31:51 (SSID='mySSID' freq=2452 MHz) rtt:~$ [00:02:55.377,227] <inf> wpa_supp: nordic_wlan0: Associated with a0:36:bc:b7:31:51 rtt:~$ [00:02:55.377,410] <inf> wpa_supp: nordic_wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0 rtt:~$ rtt:~$ [00:02:55.396,575] <inf> wpa_supp: nordic_wlan0: WPA: Key negotiation completed with a0:36:bc:b7:31:51 [PTK=CCMP GTK=CCMP] rtt:~$ [00:02:55.396,789] <inf> wpa_supp: nordic_wlan0: CTRL-EVENT-CONNECTED - Connection to a0:36:bc:b7:31:51 completed [id=0 id_str=] rtt:~$ [00:02:55.420,013] <inf> net_dhcpv4: Received: 192.168.50.78 rtt:~$ rtt:~$ wifi disconnect Disconnection request done (0) Disconnect requested rtt:~$ [00:03:08.816,040] <inf> wpa_supp: nordic_wlan0: CTRL-EVENT-DISCONNECTED bssid=a0:36:bc:b7:31:51 reason=3 locally_generated=1 rtt:~$ [00:03:08.824,188] <inf> wpa_supp: nordic_wlan0: CTRL-EVENT-DSCP-POLICY clear_all rtt:~$ rtt:~$ kernel heap free: 16404 allocated: 63004 max. allocated: 68296 rtt:~$