lwip: fix socket memory leak issue

1. Add socket memory leak debug counter
2. Fix TCP PCB leak issue
This commit is contained in:
Liu Zhi Fu
2016-11-19 14:57:42 +08:00
parent 139fdcb9ec
commit ab92d43bc6
7 changed files with 102 additions and 74 deletions

View File

@@ -18,6 +18,8 @@
#include "lwip/tcp.h"
#include "lwip/udp.h"
#include "lwip/priv/tcp_priv.h"
#include "lwip/priv/memp_priv.h"
#include "lwip/memp.h"
#define DBG_LWIP_IP_SHOW(info, ip) printf("%s type=%d ip=%x\n", (info), (ip).type, (ip).u_addr.ip4.addr)
#define DBG_LWIP_IP_PCB_SHOW(pcb) \
@@ -127,3 +129,22 @@ void dbg_lwip_udp_rxtx_show(void)
printf("TBC\n");
}
#if (ESP_CNT_DEBUG == 1)
uint32_t g_lwip_mem_cnt[MEMP_MAX][2];
extern const struct memp_desc * const memp_pools[MEMP_MAX];
void dbg_lwip_cnt_show(void)
{
int i=0;
printf("-----lwip memory counter-----\n");
printf("%6s %8s %8s\n", "index", "alloc", "free");
for (i=0; i<MEMP_MAX; i++){
printf("%6u %8u %8u\n", i, g_lwip_mem_cnt[i][0], g_lwip_mem_cnt[i][1]);
}
}
#endif