http_client_connect memory usage on connection failure

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
agmi_3321141
Level 4
Level 4
5 likes given First like received First like given

I am working around a condition when an AP to which the WICED device is connected stops unexpectedly. This can happen when AP loses internet access or somehow goes down. This usually results in a disconnect callback and my app tries to reconnect using the http_client_connect() API. At this point if I make this connect call I get an error 7014(socket close) and then 9(host down).

Repeated calls in such a situation seems to be causing memory usage growth in v6.4 as compared to v6.1.

There is a link down callback to handle a host down situation, but memory growth is concerning as this also happens on a socket close error(AP is not down, but loses internet access).

I have attached a basic test app to recreate this. It can run on both v6.4 and v6.1. I simulate by creating a hotspot to which the WICED device connects. If I close the hotspot after the test app initiates and and keep calling the connect API, memory keeps growing in v6.4 but not in v6.1. Has there been a change from 6.1 to 6.4 that would warrant a different way to handle this call - like a clean-up?

Also attached two logs when I ran the program on both versions. Platform is 43438, 1LD. Hope you can give some suggestions.

0 Likes
1 Solution

Hello,

There is a bool flag(wiced_bool_t context_malloced) which should be set in the HTTP client librray if the memory for tls context is allocated.

This flag is missing from the WICED 6.4 library and hence the respective freeing of the memory is not happening and is causing the reported issue.

Please add the following line in http_client_connect() function in /43xxx_Wi-Fi/libraries/protocols/HTTP_client/http_client.c file.

Line no 195: memset( client->tls_context, 0, sizeof( *( client->tls_context ) ) );

Add this line->    client->socket.context_malloced = WICED_TRUE;

View solution in original post

2 Replies
agmi_3321141
Level 4
Level 4
5 likes given First like received First like given

Bumping this thread

0 Likes

Hello,

There is a bool flag(wiced_bool_t context_malloced) which should be set in the HTTP client librray if the memory for tls context is allocated.

This flag is missing from the WICED 6.4 library and hence the respective freeing of the memory is not happening and is causing the reported issue.

Please add the following line in http_client_connect() function in /43xxx_Wi-Fi/libraries/protocols/HTTP_client/http_client.c file.

Line no 195: memset( client->tls_context, 0, sizeof( *( client->tls_context ) ) );

Add this line->    client->socket.context_malloced = WICED_TRUE;