As suggested above i called netconn_free() after netcon_delete() , but still facing same issue.
My Code is as following:
Code: Select all
static void server(void *pvParameters)
{
printf("\n system_get_free_heap_size in starting of server task =%d\n\n\n",system_get_free_heap_size());
struct netconn *conn , *newconn;
err_t err;
conn = netconn_new(NETCONN_TCP);
err= netconn_bind(conn, NULL, 80);
if (err == ERR_OK) {printf("\nsocket bound\n");}
netconn_listen(conn);
do{
ESP_LOGI(TAG,"\nsystem_get_free_heap_size before accept in request number %d =%d\n\n\n",++counter,system_get_free_heap_size());
err = netconn_accept(conn, &newconn);
if (err == ERR_OK)
{
ESP_LOGI(TAG,"connection accept\n");
ESP_LOGI(TAG,"\nsystem_get_free_heap_size after accept =%d\n\n\n",system_get_free_heap_size());
}
ESP_LOGI(TAG,"\nsystem_get_free_heap_size befor close newconn =%d\n\n\n",system_get_free_heap_size());
err=netconn_close(newconn);
if(err!=ERR_OK) printf("\n new con not closed\n");
ESP_LOGI(TAG,"\nsystem_get_free_heap_size after close and before delete newconn =%d\n\n\n",system_get_free_heap_size());
err_t err_newconn_d=netconn_delete(newconn);
if (err_newconn_d != ERR_OK) printf("newconn not delete succesfully\n");
ESP_LOGI(TAG,"\nsystem_get_free_heap_size after delete and befor free =%d\n\n\n",system_get_free_heap_size());
netconn_free(newconn);
ESP_LOGI(TAG,"\nsystem_get_free_heap_size after calling netconn_free =%d\n\n\n",system_get_free_heap_size());
} while(err == ERR_OK);
netconn_close(conn);
printf("conn is close\n");
netconn_delete(conn);
}
This is only task, which is running.And there is random memory leak.
my log is as following:
Code: Select all
I (1322) main: system_get_free_heap_size before accept in request number 1 =234892
I (21702) main: system_get_free_heap_size after accept =230264
I (21702) main:system_get_free_heap_size befor close newconn =230264
I (21712) main: system_get_free_heap_size after close and before delete newconn =232884
I (21722) main: system_get_free_heap_size after delete and befor free =233240
I (21732) main: system_get_free_heap_size after calling netconn_free =233300
I (21742) main:system_get_free_heap_size before accept in request number 2 =233300
I (22712) main: connection accept
I (22712) main: system_get_free_heap_size after accept =232820
I (22712) main: system_get_free_heap_size befor close newconn =231056
I (22722) main: system_get_free_heap_size after close and before delete newconn =232668
I (22732) main: system_get_free_heap_size after delete and befor free =233032
I (22742) main: system_get_free_heap_size after calling netconn_free =233092
I (22752) main: system_get_free_heap_size before accept in request number 3 =233092
I (23662) main: connection accept
I (23662) main: system_get_free_heap_size after accept =230864
I (23662) main: system_get_free_heap_size befor close newconn =230864
I (23672) main: system_get_free_heap_size after close and before delete newconn =232460
I (23682) main: system_get_free_heap_size after delete and befor free =232824
I (23692) main: system_get_free_heap_size after calling netconn_free =232884
I (23702) main: system_get_free_heap_size before accept in request number 4 =232884
I (24452) main: connection accept
I (24452) main: system_get_free_heap_size after accept =230648
I (24452) main: system_get_free_heap_size befor close newconn =230648
I (24462) main: system_get_free_heap_size after close and before delete newconn =232252
I (24462) main: system_get_free_heap_size after delete and befor free =232616
I (24472) main: system_get_free_heap_size after calling netconn_free =232676
I (24482) main: system_get_free_heap_size before accept in request number 5 =232676
I (25592) main: connection accept
I (25592) main: system_get_free_heap_size after accept =230440
I (25592) main: system_get_free_heap_size befor close newconn =230440
I (25602) main: system_get_free_heap_size after close and before delete newconn =232044
I (25612) main: system_get_free_heap_size after delete and befor free =232408
I (25622) main: system_get_free_heap_size after calling netconn_free =232468
I (25632) main: system_get_free_heap_size before accept in request number 6 =232468
I (879372) main: connection accept
I (879372) main: system_get_free_heap_size after accept =229896
I (879372) main: system_get_free_heap_size befor close newconn =229896
I (879382) main:system_get_free_heap_size after close and before delete newconn =231720
I (879392) main: system_get_free_heap_size after delete and befor free =231856
I (879402) main: system_get_free_heap_size after calling netconn_free =231916
I (879412) main: system_get_free_heap_size before accept in request number 7 =231916
I (892582) main: connection accept
I (892582) main: system_get_free_heap_size after accept =229352
I (892582) main: system_get_free_heap_size befor close newconn =229436
I (892592) main: system_get_free_heap_size after close and before delete newconn =231292
I (892602) main: system_get_free_heap_size after delete and befor free =231648
I (892612) main: system_get_free_heap_size after calling netconn_free =231708
I (892622) main: system_get_free_heap_size before accept in request number 8 =231708
I (925662) main: connection accept
I (925662) main: system_get_free_heap_size after accept =230524
I (925662) main: system_get_free_heap_size befor close newconn =230524
I (925672) main: system_get_free_heap_size after close and before delete newconn =230368
I (925672) main: system_get_free_heap_size after delete and befor free =230600
I (925682) main: system_get_free_heap_size after calling netconn_free =230660
I (925692) main: system_get_free_heap_size before accept in request number 9 =230660
I (925802) main: connection accept
I (925802) main: system_get_free_heap_size after accept =230872
I (925802) main: system_get_free_heap_size befor close newconn =230872
I (925812) main: system_get_free_heap_size after close and before delete newconn =230716
I (925822) main: system_get_free_heap_size after delete and befor free =230948
I (925832) main: system_get_free_heap_size after calling netconn_free =231008
I (925842) main: system_get_free_heap_size before accept in request number 10 =229268
Also I saw memory is released after calling netcon_freee(), but its only 60 bytes.where dose other bytes consumed?
Using reference of
https://github.com/cmmakerclub/esp32-webserver we made application, but we saw memory leakage in it , after debugging we found this issue.
So, I would like to know that, is there any proper solution for lwip netcon library ? Or we have to use socket API?
Am i Missing anything?