本人用“探索者STM32F4”开发平台,用LWIP做tcp_client连接服务器--发数--断开后再连接服务器--发数--断开,3秒钟循环此操作一次。775次操作后申请内存失败,每操作一次内存就减少20个字节,直至内存用完(观察mem,ram_end和Ifree指针变量)。在断开连接后也操作了“ if(es)mem_free(es); ”,不知是什么原因,望各位大师指教,谢谢
void tcp_client_connect_remotehost(void)
{
if((tcp_client_flag&1<<5)!=0)
{
tcp_client_connection_close(tcp_client_pcb,0);
}
tcp_client_pcb=tcp_new();
if(tcp_client_pcb)
{
tcp_connect(tcp_client_pcb,&rmtipaddr,TCP_CLIENT_PORT,tcp_client_connected);
}
}
void tcp_client_connection_close(struct tcp_pcb *tpcb, struct tcp_client_struct * es)
{
tcp_abort(tpcb);
tcp_arg(tpcb,NULL);
tcp_recv(tpcb,NULL);
tcp_sent(tpcb,NULL);
tcp_err(tpcb,NULL);
tcp_poll(tpcb,NULL,0);
if(es)mem_free(es);
tcp_client_flag&=~(1<<5);
}