Page 1 of 4

Memory Leak/Usage

Posted: Thu Jul 23, 2015 4:41 pm
by zaxl
Hi,

I'm using the memory optimized SDK 1.2.0.

The issue is that my tcp disconnect callback is not called and each accepted tcp connection leaks between 108 and 288 bytes.
/Will figure exact number but this is from a timer that runs every second to report free heap/.
Tried to set option REUSEADDR but does not make any difference.
I'm using code based on the esp_httpd .
init ....
espconn_regist_connectcb(&httpdConn, httpdConnectCb);
espconn_tcp_set_max_con_allow(&httpdConn, MAX_CONN);
espconn_set_opt(&httpdConn, ESPCONN_REUSEADDR);
espconn_accept(&httpdConn);

static void ICACHE_FLASH_ATTR httpdConnectCb(void *arg) {
....
....
espconn_regist_recvcb(conn, httpdRecvCb);
espconn_regist_reconcb(conn, httpdReconCb);
espconn_regist_disconcb(conn, httpdDisconCb);
espconn_regist_sentcb(conn, httpdSentCb);

}

I'm closing the connection from my main loop but httpdDisconCb is not called.

The incoming connection limit is a kind of useless - with 2 minutes timewait i can generate enough connections to trigger an out of memory condition. Connect/Close 200 bytes per connection about 100 connections and the device is OOM.
What is the way to deal with TCP memory in general?


Regards

Re: Memory Leak/Usage

Posted: Mon Aug 03, 2015 10:06 am
by ESP_Faye
Hi,

So sorry for the inconvenience. Could you provide your test code ? We will have a try.

espconn_regist_reconcb(conn, httpdReconCb);
espconn_regist_disconcb(conn, httpdDisconCb);

If the TCP connection broke unexpected, httpdReconCb will be called.
If espconn_disconnect is called or normally TCP disconnect, it will enter httpdDisconCb.

Re: Memory Leak/Usage

Posted: Wed Aug 05, 2015 2:01 pm
by zaxl
Hi,

I'm working on a test case code, i'll give it out when ready.
My code flow is like this:
1. listen on port 80 -> web server
2. outbound ssl connection to server. close connection
3. start normal connection to server - long lived

So far i found out that:
If there is only listen on port 80 -> disconnect callback is called - no leak
If there is outbound connection /don't know which one is causing the problem yet/ -> disconnect callback is not called and it leaks.

Re: Memory Leak/Usage

Posted: Sun Aug 09, 2015 8:52 am
by ESP_Faye
Hi,

Please have a try with the latest sdk_v1.3.0 http://bbs.espressif.com/viewtopic.php?f=46&t=918&p=3092

If your problem is still unsolved, please provide your test code. We will debug it.

Thanks for your interest in ESP8266!

Re: Memory Leak/Usage

Posted: Mon Aug 10, 2015 2:28 pm
by mharizanov
I can confirm the exact same: I am running MQTT over TLS and esphttpd over non-TLS connection. As of SDK 1.2 the disconnect callback on non-TLS connections (esphttpd) is broken and if there is a SSL connection active (MQTT in my case). As a result, there is a memory leak introduced. If I run the MQTT client over non-TLS, all work just fine and disconnect callback gets called.
I tried with SDK 1.2 and 1.3 and it fails with both. It works just as expected with SDK 1.1

Re: Memory Leak/Usage

Posted: Mon Aug 10, 2015 4:33 pm
by ESP_Faye
Hi,

So sorry for the inconvenience.

Please update to esp_iot_sdk_v1.3.0 and try the SSL patch here http://bbs.espressif.com/viewtopic.php?f=46&t=925

Please have a try. If your problem is still unsolved, feel free to let us know !

Thanks for your interest in Espressif Systems and ESP8266 !

Re: Memory Leak/Usage

Posted: Tue Aug 11, 2015 1:17 am
by mharizanov
The patch fixes the issue and all works as expected, thanks!

SSL example

Posted: Wed Aug 12, 2015 12:33 am
by hdrut
Hi,

I'm trying to implement the SSL example provided by Espressif, but get the following errors I can't debug:

undefined reference to `espconn_secure_sent'
undefined reference to `espconn_secure_connect'


Any help is appreciated.


Rgds

Re: SSL example

Posted: Wed Aug 12, 2015 3:15 pm
by rudi
hdrut wrote:Hi,

I'm trying to implement the SSL example provided by Espressif, but get the following errors I can't debug:

undefined reference to `espconn_secure_sent'
undefined reference to `espconn_secure_connect'


Any help is appreciated.


Rgds



think you simple forget "to add" the ssl lib in makefile?

example:

Code: Select all


LIBS        = c gcc hal phy pp net80211 lwip wpa upgrade main ssl



write please, how you get on in this.

best wishes
rudi ;-)

Re: SSL example

Posted: Wed Aug 12, 2015 8:14 pm
by hdrut
Hi Rudi

yes! That was the problem, how silly of me :)

How are you doing? Have you managed to do some progress on copy protection for ESP?

I am now trying SSL communication, just started...



Cheers, i am going to celebrate my birthday today !!

Hope to hear from you soon, wish all is fine with you Rudi, :)

Horacio




rudi wrote:
hdrut wrote:Hi,

I'm trying to implement the SSL example provided by Espressif, but get the following errors I can't debug:

undefined reference to `espconn_secure_sent'
undefined reference to `espconn_secure_connect'


Any help is appreciated.


Rgds



think you simple forget "to add" the ssl lib in makefile?

example:

Code: Select all


LIBS        = c gcc hal phy pp net80211 lwip wpa upgrade main ssl



write please, how you get on in this.

best wishes
rudi ;-)